| « | October 2025 | » | | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | |
| 公告 |
|
| Blog信息 |
|
blog名称:流浪狗 日志总数:44 评论数量:19 留言数量:-2 访问次数:192937 建立时间:2008年3月13日 |

| |
|
[struts2学习之路]prototype+json ajax应用 软件技术
流浪狗 发表于 2010/8/18 23:44:34 |
| 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); } }); |
|
|