It's really easy to make a POST request through AJAX using JavaScript and then attach some data to send with that. This technique can be used to communicate with your server without refreshing the page and even feed it some useful information.
In this video I take you through a simple example of how this works by first setting up the request in JavaScript and then coding a simple PHP script which will do a basic manipulation of the POST variables. From there, we display the server response to the browser.
For your reference, check this out:
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/send0:00 Overview
0:35 Creating XHR Object
0:52 Handling the response
2:08 Sending the request
4:46 Verifying that it works
5:48 Wrapping up
Follow me on Twitter @dcode!
If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
#dcode #javascript #webdev
127 Comments