Message from JavaScript talks

May 2017

— (ajax)


You can either turn the button element into a div instead, then addEventListener to an XMLHttpRequest

— Or call preventDefault on the button, while doing the former

— Ok

— Https://

— This is a snippet I use a lot

— That looks really helpful

— If I used ajax, how does the server send back data? Does it just go back to the handler?

— ajax("/formInterface", "json", myFormData).then(callback);

— callback gets the response data as a parameter

— Also has built in error handling

— ajax("/formInterface", "json", myFormData).then(callback).catch(callback);