-2

I have a form with action attribute and within: input text and submit. When the user presses submit, the information they provided will be used to send a text message using Twilio. My question is how do I do this without reloading the page or going to another a page? Instead, I would rather have a cool small animation that displays whether it sent successfully or not, with the page remaining the same.

Thank you for your help. Much appreciated!

koz
  • 195
  • 1
  • 13
  • 2
    You have to add a listener to the `submit` event on the form and prevent the default event behaviour with `event.preventDefault()`. See here: http://stackoverflow.com/questions/7410063/how-can-i-listen-to-the-form-submit-event-in-javascript – zeronone Apr 22 '17 at 07:49

1 Answers1

0

I basically did what zeronone said with listener on submit event, but instead wrote "return false;" preventing the page reload. I then included ajax, and the rest of the code remained basically the same.

koz
  • 195
  • 1
  • 13