Chapter 18 Answers
- Question 18-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 code will work on all major browsers.- Question 18-2
The purpose of the
try...catch
construct is to set an error trap for the code inside thetry
statement. If the code causes an error, thecatch
section will be executed instead of a general error being issued.- Question 18-3
An
XMLHTTPRequest
object has six properties and six methods (see Tables 18-1 and 18-2).- Question 18-4
You can tell that an Ajax call has completed when the
readyState
property of an object has a value of 4.- Question 18-5
When an Ajax call successfully completes, the object’s
status
will have a value of 200.- Question 18-6
The
responseText
property of anXMLHTTPRequest
object contains the value returned by a successful Ajax call.- Question 18-7
The
responseXML
property of anXMLHTTPRequest
object contains a DOM tree created from the XML returned by a successful Ajax call.- Question 18-8
To specify a callback function to handle Ajax responses, assign the function name to the
XMLHTTPRequest
object’sonreadystatechange
property. You can also use an unnamed, inline function.- Question 18-9
To initiate an Ajax request, an
XMLHTTPRequest
object’ssend
method is called.- Question 18-10
The main differences between an Ajax
GET
andPOST
request are that ...
Get Learning PHP, MySQL, and JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.