The first parameter specifies the method used to send data to the server page;
the usual values are GET and POST. The second parameter is URL, which specifies where you want
to send the request. The URL can be complete or relative. If the URL doesn??™t specify a resource
accessible via HTTP, the first parameter is ignored.
The third parameter of open(), called async, specifies whether the request should be handled
asynchronously. true means that your code processing carries on after send() returns without
waiting for a response from the server; false means the script waits for a response before
continuing processing. To enable asynchronous processing (which is the heart of the AJAX
mechanism), you will need to set async to true and handle the onreadystatechange event to
process the response from the server.
After configuring the connection with open(), you execute it using send(). When making
a GET request, you send the parameters using the URL query string, as in http://localhost/ajax/
test.php?param1=x¶m2=y. This server request passes two parameters to the server??”a parameter
called param1 with the value x and a parameter called param2 with the value y:
CHAPTER 13 ?– IMPLEMENTING AJAX FEATURES 405
// Call the server to execute the server-side operation
xmlHttp.open("GET", "http://localhost/ajax/test.php?param1=x¶m2=y", true);
xmlHttp.
Pages:
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520