为什么 Mootools 的新 Request 类什么都不做...或者忽略我?

发布于 2024-12-22 03:08:26 字数 933 浏览 3 评论 0原文

我正在为 Joomla 1.7 开发一个组件,Joomla 1.7 可以与 Mootools 1.3 一起使用。在此之前,mootools中正确的做法是Ajax类。但在 Mootools 中,正如我所读到的,我必须使用 Request 类。

好的,当我尝试使用 Request 类并使用 Google Inspector 逐步调试 Request 定义和 Request send() 调用时。我可以看到,它执行发送,但什么也不做(忽略 onSuccess、忽略 OnException 等)。

如果我查看 chrome javascript 控制台,什么也没有。

function addValue(value) {
    var id = $('selectedval').getProperty('value');
    var url = 'index.php?option=com_kaltura&controller=fieldsmanager&task=additem&tmpl=component';
    var req = new Request(url, {
        method: 'post',
        data: {
            'id': id,
            'value': value
        },
        onRequest: function(event, xhr) {alert('gogogo'); },
        onFailure: function(xhr) { alert('failure'.xhr); },
        onException: function(test) {alert(test); },
        onSuccess: function(data) {
            loadFieldList(data);
        }
    });
    req.send();
}

I'm working on a component for Joomla 1.7, and Joomla 1.7 works with Mootools 1.3. Before that, the correct way in mootools was Ajax class. But in Mootools, as I read, I must use Request class.

Ok, when I try to use the Request class and take a look with Google Inspector debuging step by step the Request definition and Request send() call. I can see that, it execs the send but it does nothing (ignores onSuccess, ignores OnException, etc).

And if I look on chrome javascript console there's nothing.

function addValue(value) {
    var id = $('selectedval').getProperty('value');
    var url = 'index.php?option=com_kaltura&controller=fieldsmanager&task=additem&tmpl=component';
    var req = new Request(url, {
        method: 'post',
        data: {
            'id': id,
            'value': value
        },
        onRequest: function(event, xhr) {alert('gogogo'); },
        onFailure: function(xhr) { alert('failure'.xhr); },
        onException: function(test) {alert(test); },
        onSuccess: function(data) {
            loadFieldList(data);
        }
    });
    req.send();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜清冷一曲。 2024-12-29 03:08:26

API 已从 1.1x 更改为 1.2 -> Request 现在采用一个参数对象,该对象会重载您需要的所有选项,包括 url - 以前是arguments[0]。

换句话说 - 将 url 从那里移动到选项对象的属性中:

new Request({
    url: url,
    method: 'post',
    data: {
        'id': id,
        'value': value
    },
    onRequest: function(event, xhr) {alert('gogogo'); },
    onFailure: function(xhr) { alert('failure'.xhr); },
    onException: function(test) {alert(test); },
    onSuccess: function(data) {
        loadFieldList(data);
    }
}).send();

the api has changed from 1.1x to 1.2 -> Request now takes a single argument object that overloads all options you need, INCLUDING url - which used to be arguments[0] before.

In other words - move the url from there into a property of the options object:

new Request({
    url: url,
    method: 'post',
    data: {
        'id': id,
        'value': value
    },
    onRequest: function(event, xhr) {alert('gogogo'); },
    onFailure: function(xhr) { alert('failure'.xhr); },
    onException: function(test) {alert(test); },
    onSuccess: function(data) {
        loadFieldList(data);
    }
}).send();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文