Home arrow JavaScript arrow Page 2 - AJAX with JSON
JAVASCRIPT

AJAX with JSON


In my previous article I discussed some of the basics of JSON, the JavaScript Object Notation. It is an object literal notation well suited for data exchange. The object and arrays of JSON are very similar to real world data representation in many programming languages and this makes it a natural competitor with the more ubiquitous XML.

Author Info:
By: Jayaram Krishnaswamy
Rating: 4 stars4 stars4 stars4 stars4 stars / 20
March 12, 2007
TABLE OF CONTENTS:
  1. · AJAX with JSON
  2. · Retrieving JSON Text using AJAX
  3. · The XMLHTTP Request to retrieve JSON
  4. · Output formatting

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
AJAX with JSON - Retrieving JSON Text using AJAX
(Page 2 of 4 )

The JSON Text on the web server

In the previous article an equivalent JSON object which has the same structure as the webstudents.xml file was developed using the basic features of the JSON. In particular the following object representing the XML file except for the comment node can also be added if necessary.

var studentAll={"wclass":[
{"student":{"id":"1"},"name":"Linda Jones", "legacySkill":"Access, 
VB 5.0"}, {"student":{"id":"2"},"name":"Adam Davidson", "legacySkill":"Cobol,
MainFrame"}, {"student":{"id":"3"},"name":"Charles Boyer", "legacySkill":"HTML, XML"} ]};

The JSONWebStudents.txt file is the textual representation of this serialized object. The JSONWebStudents.txt file is shown in the next listing. This is the file that will be retrieved when the AJAX call is made. Just insert the listing shown in Notepad and save it to the root directory of your server. Notice there is no semi-colon at the end.

Listing of JSONWebStudents.txt:

{"wclass":
[{"student":{"id":"1"},"name":"Linda Jones", "legacySkill":"Access, 
VB 5.0"}, {"student":{"id":"2"},"name":"Adam Davidson", "legacySkill":"Cobol,
MainFrame"}, {"student":{"id":"3"},"name":"Charles Boyer", "legacySkill":"HTML,
XML"}]}


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks
- Dynamic jQuery Styling

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials