• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

The beauty of JSON with AJAX ...

JSON is a subset of the JavaScript that provides a fairly terse, dense data notation. When passed as data client-side it can be deserialized into a JavaScript Object with one line of code. In contrast XML is bulky and requires a fair bit of code client-side to parse and work with it. I believe that the denser notation and client side ease of use make JSON a ideal data transfer format for AJAX.

Lets take a quick look at some data in both XML and JSON formats...

XML:
<Table>
<Rows>
<Row><Item>1.1</Item><Item>1.2</Item></Row>
<Row><Item>2.1</Item><Item>2.2</Item></Row>
</Rows>
</Table>

JSON:
{Rows:[{Item:[1.1,1.2]}{Item:[2.1,2.2]}]}

The leaner format can cut the size of your data in half and while you do loose a bit of the human readability with JSON, you can always use a tool like Charles to break it out into a tree view when debugging. The real beauty of JSON, however, is the ease of working with it on the client. If you deserialized the data into a variable called DataTable you can read first item in the second row by doing this:

DataTable .Rows[1].Item[0];

The trade off is that you will get cleaner, smaller client side code in exchange for more work getting your data into JSON on the server. Personally I would rather have the extra code on the server where it can be unit tested and easily debugged than on the client where it can .

Some might say that if you aren using XML then you aren doing AJAX. I disagree. I think that AJAX is actually a misnomer and so is the XMLHttpRequest object that it uses. XMLHttpRequest doesn require that your data be in XML and will accept any format you choose. Believe it or not even JavaScript isn even required to do AJAX; I hear VBScript works with XMLHttpRequest just fine.

I think that we have missed the big picture; JavaScript and XML aren the reason why AJAX is such a phenomenal tool... it is the Asynchronous HTTP requests that it provides that make it so powerful. Also DOM scripting and DHTML are not AJAX, although they are used quite effectively in conjunction with it to provide the rich features that everyone associates with AJAX. The bottom line is that any site that makes Asynchronous HTTP requests is using AJAX and any site that doesn , isn .

The irony is that the one technology that is actually required for AJAX, HTTP, isn even in the name. I think that AJAX would be better called Asynchronous HTTP-Request Scripting. Sadly AHS will never have the marketing appeal of the cool sounding AJAX, so we are stuck. As for the purists out there, I am sure you would prefer that I say that I am recommending "Asynchronous HTTP request scripting with JavaScript and JSON" than for me to talk about using JSON with AJAX. Sorry no such luck.

source: coderenaissance

 View Full Story.

AddThis Social Bookmark Button

Posted at 11:14:55 am | Permalink | Posted in JSON  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

Top Stuff

e-messenger

MessengerFX

eBuddy

ILoveIM

AIM Express

Top 20 Ruby CMS


Death Poems

Best Death Poems

Flex Development

Hight quality AJAX development at low prices

Wordpress Themes

Unique Themes & Templates for wordpress, download and create your own.

Stock Exchange Chat

Stock exchange community, chat room for each quote

FreeTube

FreeTube Online TV is a web 2.0 video site that uses ajax and rss to play videos and online streams that users can contribute and manage.

Brian Tracy Videos

Self help, Self Improvement videos for Brian Tracy

eBuddy

Ebuddy full review, tips and screen shots.

self improvement

Different articles about self improvement

Facebook Applications

Do you want to know the latest facebook applications?

Cotton towels

Visit Aqttan online store for famous egyptian cotton home textile products.


About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Search


Topics

  • .Net (118)
  • Ajax (24)
  • Ajax Games (10)
  • Articles (95)
  • Bookmarking (35)
  • Calendar (19)
  • Chat (41)
  • ColdFusion (3)
  • CSS (52)
  • Email (23)
  • Facebook (47)
  • Flash (17)
  • Google (36)
  • Html (17)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (41)
  • Javascript (196)
  • jQuery (11)
  • JSON (26)
  • Perl (2)
  • PHP (101)
  • Presentation (19)
  • Python (3)
  • Resources (2)
  • RSS (2)
  • Ruby (16)
  • Storage (4)
  • Toolkits (96)
  • Tutorials (203)
  • UI (12)
  • Utilities (173)
  • Web2.0 (18)
  • XmlHttpRequest (22)
  • YUI (4)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange