O'Reilly logo

Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition by Robin Nixon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17 Answers

  1. It’s necessary to write a function for creating new XMLHTTPRequest objects because Microsoft browsers use two different methods of creating them, while all other major browsers use a third. By writing a function to test the browser in use, you can ensure that your code will work on all major browsers.

  2. The purpose of the try...catch construct is to set an error trap for the code inside the try statement. If the code causes an error, the catch section will be executed instead of a general error being issued.

  3. An XMLHTTPRequest object has six properties and six methods (see Tables 17-1 and 17-2).

  4. You can tell that an Ajax call has completed when the readyState property of an object has a value of 4.

  5. When an Ajax call successfully completes, the object’s status property will have a value of 200.

  6. The responseText property of an XMLHTTPRequest object contains the value returned by a successful Ajax call.

  7. The responseXML property of an XMLHTTPRequest object contains a DOM tree created from the XML returned by a successful Ajax call.

  8. To specify a callback function to handle Ajax responses, assign the function name to the XMLHTTPRequest object’s onreadystatechange property. You can also use an unnamed, inline function.

  9. To initiate an Ajax request, an XMLHTTPRequest object’s send method is called.

  10. The main differences between Ajax GET and POST requests are that GET requests append the data to the URL, while POST requests instead pass the data as a parameter of the send method and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required