javascript - mootools中使用Ajax加载文件

标签 javascript jquery ajax

我在 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/

相关文章:

javascript - 文件上传后提交 Jquery 表单

javascript - 如何从 Accordion 中执行 javascript

javascript - 在 Flux 中处理同一组件的多个实例

javascript - React中类变量和函数变量有什么区别

javascript - 在 jQuery mousedown 处理程序中添加覆盖后,Internet Explorer 会泄漏单击事件

jquery - 在 Django 中使用 AJAX/jQuery 删除对象

javascript - 如何进行 6 个以上并发 REST API 调用

javascript - Windows 8 html/js : Alternative to <img>/removing the 'dragging' functionality?

javascript - 在元素 SVG 中使用 JavaScript 或 jQuery 事件点击?

javascript - 单击按钮时从表中删除成员