Welcome Guest, Not a member yet? Register   Sign In
AJAX Response
#4

[eluser]TheFuzzy0ne[/eluser]
Here's an example of a JSON object in JavaScript.

Code:
var dog = {
    name: 'Bob',
    breed: 'German Sheppard',
    age: 4
}

To access the data, you'd do something like this:
Code:
var msg = "My dog is called" + dog.name;
console.log(msg);

This is basically an object in JavaScript. Objects can also hold functions, but you shouldn't need to pass any functions back. When you get the data from the server, you'll need to eval() it to turn it into a usable object.

Here's some more information on JSON from a fairly well known person on the JavaScript scene. http://www.dustindiaz.com/json-for-the-masses/


Messages In This Thread
AJAX Response - by El Forum - 02-21-2009, 09:12 PM
AJAX Response - by El Forum - 02-21-2009, 10:06 PM
AJAX Response - by El Forum - 02-21-2009, 10:25 PM
AJAX Response - by El Forum - 02-21-2009, 10:59 PM
AJAX Response - by El Forum - 02-23-2009, 09:50 PM
AJAX Response - by El Forum - 02-24-2009, 05:51 AM
AJAX Response - by El Forum - 02-24-2009, 09:10 AM
AJAX Response - by El Forum - 02-24-2009, 12:22 PM
AJAX Response - by El Forum - 02-24-2009, 12:46 PM
AJAX Response - by El Forum - 02-24-2009, 12:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB