http://mootools.net/demos/?demo=Request.JSON
点击load JSON Data
时加载JSON数据。
是否可以在页面打开时加载此数据(类似onload
的功能)
答案 0 :(得分:2)
<head>
<script type="text/javascript">
window.addEvent("domready",function(){
var request = new Request.JSON({
url: '/echo/json/',
onRequest: function(){
gallery.set('text', 'Loading...');
},
onComplete: function(jsonObj) {
gallery.empty();
addImages(jsonObj.previews);
},
data: { // our demo runner and jsfiddle will return this exact data as a JSON string
json: JSON.encode(data)
}
}).send();
});
</script>
</head>