Ajax在mootools中使用来加载文件

Ajax using in mootools to load file

本文关键字:加载 文件 mootools Ajax      更新时间:2024-02-16

我在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类:请求