wiseboyloves 发表于 2013-1-29 11:49:57

prototype+json ajax应用

Using JSON with Ajax

Using JSON with Ajax is very straightforward, simply invoke String#evalJSON on the transport’s responseText property:
 
new Ajax.Request('/some_url', {   method:'get',   onSuccess: function(transport){      var json = transport.responseText.evalJSON();    } });  
If your data comes from an untrusted source, be sure to sanitize it:
 
new Ajax.Request('/some_url', {   method:'get',   requestHeaders: {Accept: 'application/json'},   onSuccess: function(transport){   var json = transport.responseText.evalJSON(true);   } });
页: [1]
查看完整版本: prototype+json ajax应用