AJAX sending data
We have created the AJAX object, and the form to retrieve the data from the web server using AJAX, now how do we actually get that data? To do so, we will have to use a few special methods.
This tutorial focuses on:
- The open() method
- The send() method
- A complete AJAX example
The open() method
The open() method is used to get the server side script that will be used in an AJAX application.
This method takes three parameters:
Specifies the method by which to get the script. Can take the value of "GET" or "POST"
The URL of the script
Takes the value of "true" or "false" specifying if the request should be handled asynchronously
The send() method
The send() method sends the actual request to the server. It should contain the value "null"
A complete AJAX example
The following is a complete AJAX example. Enter your name into the first text box, and the second text box will display some text automatically. The AJAX will get the data from the file advice.php