3 Contains <Json.Remote>.
11 Wrapped XHR with automated sending and receiving of Javascript Objects in Json Format.
14 url - the url you want to send your object to.
15 options - see <XHR> options
18 this code will send user information based on name/last name
20 var jSonRequest = new Json.Remote("http://site.com/tellMeAge.php", {onComplete: function(person){
21 alert(person.age); //is 25 years
22 alert(person.height); //is 170 cm
23 alert(person.weight); //is 120 kg
24 }}).send({'name': 'John', 'lastName': 'Doe'});
28 Json.Remote = XHR.extend({
30 initialize: function(url, options){
32 this.addEvent('onSuccess', this.onComplete);
34 this.setHeader('X-Request', 'JSON');
38 return this.parent(this.url, 'json=' + Json.toString(obj));
41 onComplete: function(){
42 this.fireEvent('onComplete', Json.evaluate(this.response.text, this.options.secure));