为什么 Mootools 的新 Request 类什么都不做...或者忽略我?
我正在为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
API 已从 1.1x 更改为 1.2 -> Request 现在采用一个参数对象,该对象会重载您需要的所有选项,包括 url - 以前是arguments[0]。
换句话说 - 将 url 从那里移动到选项对象的属性中:
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: