Sending an AJAX Request to a Server

To send a request to a Web server, use the open() and send() methods.

The open() method takes three arguments. The first argument defines which method to use (GET or POST). The second argument specifies the name of the server resource (URL). The third argument specifies if the request should be handled asynchronously.

The send() method sends the request off to the server. If we assume the file requested is called time.asp, the code would be:

url="time.asp"

 xmlhttp.open("GET",url,true);

 xmlhttp.send(null);

 In the example, we assume that the current Web page and the requested resource are both in the same file directory