【发布时间】:2016-03-03 11:55:31
【问题描述】:
MooTools 中是否有任何 jQuery.getJSON() 等价物?我有一个名为 data.json 的 json 文件,我想通过使用 MooTool 调用 data.json 文件来获取它的内容。可能吗?我尝试了Request.JSON() 方法,但它对我不起作用。以下是我的代码,
var json_req = new Request.JSON({
url:'../public_html/data/data.json',
method: 'get',
secure: true,
data:{
json: true
},
onSuccess: function (res){
this.result = res;
},
onFailure: function(){
this.result = "failed";
}
}).send();
同样来自http://demos111.mootools.net/,我发现了一个名为 Ajax() 的 Ajax 类,他们在整个教程中都广泛使用该类。但是在 MooTools 文档中我没有找到这个 Ajax() 类。我尝试通过替换我的 Request.JSON() 来使用 Ajax(),但得到了“Ajax 未定义”错误。这个 Ajax 类是什么,我们如何在 MooTools 中使用它?
【问题讨论】:
-
您使用的是什么版本的 MooTools?
-
我正在使用 MooTools 1.6.0
-
你是如何使用代码的?
this.result是什么?是来自您代码的其他部分吗?您能否显示更多代码,以便我们了解您如何使用请求。 Request.JSON 等价于 jQuery.getJSON。
标签: ajax mootools mootools-events