我在 mootools 中遇到了 ajax 问题。是否可以在 mootools 中加载一些与 jQuery 相同的内容,因为我在 mootools 中找不到有关 ajax 的任何内容。我的要求很简单,看起来就是这样。有人可以帮助我吗?
/////////////////////////////////////////////
var json = (function () {
var json = null;
$.ajax({
'async': false,
'url': '/a/b/c.json',
'dataType': "json",
'success': function (data) {
json = data;
}
});
return json;
})();
//////////////////////////////
最佳答案
尝试这样:
var myRequest = new Request({
url: 'fileName.php', // here or in the form html tag "action="fileName.php"
method: 'get', //or post
onRequest: function(){
myElement.set('text', 'loading...');
},
onSuccess: function(responseText){
myElement.set('text', responseText);
},
onFailure: function(){
myElement.set('text', 'Sorry, your request failed :(');
}
});
有关更多详细信息,请参阅:mootools class:Request
关于javascript - mootools中使用Ajax加载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28627975/