MooTools中是否有任何jQuery.getJSON()
等效?我有一個名爲data.json的json文件,我想通過使用MooTool調用data.json文件來獲取它的內容。可能嗎?我嘗試了Request.JSON()
方法,但它不適合我。以下是我的代碼,jQuery.getJSON等效於MooTools
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類。但在MooTools文檔中,我沒有找到這個Ajax()類。我試圖通過替換我的Request.JSON()來使用Ajax(),但得到了「Ajax not defined」錯誤。什麼是Ajax類,我們如何在MooTools中使用它?
什麼版本的MooTools的您使用的是? – Sergio
我正在使用MooTools 1.6.0 –
你如何使用代碼?什麼是「this.result」?是從你的代碼的其他部分?你能展示更多的代碼,以便我們瞭解你如何使用請求。 Request.JSON相當於jQuery.getJSON。 – Sergio