1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

Introduction to Ajax

10. Javascript Object Notation

clr gif

There are a number of standard formats that have been adopted for AJAX to use to pass the response back from the server. The one that gives AJAX its name is XML. Another is JSON (Javascript Object Notation). As JSON is related to Javascript and produces a more compact response we will use this as our format of choice in the next few tutorials.

In order to use JSON to return the information from the server we will need to do a couple of things:

  • the server script will need to create the response in JSON format and pass it back as plain text
  • The JSON code will need to be converted into regular Javascript in order to be able to use it to update the current web page.

The easiest way to convert our JSON code into Javascript is to use the json.js utility that JSON "inventor" Douglas Crockford created for this purpose. With that utility (itself written in Javascript) attached to our web page we can easily convert the JSON response into a Javascript object using one line of code:

var respObj = JSON.parse(response);

Once we have the response in a Javascript object we can then use the information from the object to update the web page (see the DOM tutorials for more details on how to do that part).

See More About

©2016 About.com. All rights reserved.