How easy is JSON?

Although i’ve done a few AJAX’y things over the past year, i’ve yet to touch AJAJ.

After reading about Aral’s SWXFormat, I thought it would be a good idea to familiarise myself with JSON, so when it looked like i’d have to use some AJAX in my portfolio, I looked up a JSON example, and I must say i’m pleasantly surprised that using JSON with jQuery can be so simple.

Here’s the JSON:
[js]
{
“wintitle”: “Window Title”,
“url”: “http://domain.com”,
“height”: 415, “width”: 720
}
[/js]

And this is JS loading the JSON (using jQuery):
[js]
$.getJSON(”http://domain.com/script.php”,
{ field: “value” }, // send field value pairs
function(json){//return function
GB_showCenter(json.wintitle, json.url,json.height,json.width)
});
[/js]

How simple is that! All that time i spent parsing XML in javascript is over, yey!

As soon as i have a spare minute i’m going to create some swxformat tests – looks like it could be an even easier way to get data into flash!

Bookmark and Share

0 Response to “How easy is JSON?”


  • No Comments

Leave a Reply

Additional comments powered by BackType