../../../../wiki/mootorial/07-request/request.json.js
Here is the documentation for ../../../../wiki/mootorial/07-request/request.json.js.
Request.JSON is a wrapper class for XHR to handle automated sending and receiving of Javascript Objects in Json Format.
Basic Syntax:
var myJsonRequest = new Request.JSON(url, options)
I can't really demonstrate what this does in this tutorial, but here's an example of what you might do with it:
var jSonRequest = new Request.JSON(http://site.com/tellMeAge.php, onComplete: function(person){ alert(person.age); //is 25 years alert(person.height); //is 170 cm alert(person.weight); //is 120 kg }).send({'name': 'John', 'lastName': 'Doe'});
In the example above, we send "John Doe" to our tellMeAge.php which presumably looks up some information about that person and returns it in a Json format that looks something like:
{ age: "25 years", height: "170 cm", weight: "120 kg", name: "John", lastName: "Doe" }
Note that the Request.JSON class's .send method that takes a JavaScript object.
mootorial/07-request/02-request.json.txt · Last modified: 2008/08/13 20:03