MooTools - JSON

MooTools={version:1.3,build:a3eed692dd85050d80168ec2c708efe901bb7db3}

Short example - JSON request with Mootools.

<script>
window.addEvent(domready, function(){
   $(link).addEvent(click, function(e) {
      e = new Event(e).stop();
      new Request.JSON({
      onFailure: function(){alert(Error);},
      onSuccess: function(person){alert(person.name+' - '+person.age+' - '+person.height+' - '+person.weight);},
      url: json.php
      }).post({
      name: John
      });   
   });
});
</script><div id=link>Get JSON</div>
<?php$result[name] = $_GET[name];$result[age]='25 years';$result[height]='180 cm';$result[weight]='80 kg';header('Content-type: application/json');echo json_encode($result);?>

Related Posts

Request.HTML MooTools 1.2, Simplexml load file + request to xml, 414 Request-URI Too Large - MooTools