HTML and CSS Reference
umentation can be found at json.org/js.html.
This function is where the server's response is handled and parsed. The XML-
HttpRequest object, called httpRequest in this example, was returned from the
functions not listed but found in Example 18.1.
The XMLHttpRequest object's responseText property contains the response from the
server request, a string of text from the “ajaxCar.json” file (see Figure 18.24).
The JSON.parse method from the json2 library takes a string and turns it into a
The special for loop is going through all the properties in the carObject , retrieving
both properties and values to be placed in the div container on line 7.
The JSON file will be requested from the server. It has a .json extension. The URL
might be http://localhost/ajaxCar.json , depending on your browser.
The < div > tag is given an id called “data”. See Figure 18.25.
Figure 18.24 The JSON string.