在使用Joomla的mootools设置Ajax请求 [英] Set ajax request in joomla using mootools
问题描述
我有一个概率在使用Joomla的mootools Ajax请求。
I am having a prob for ajax request in joomla using mootools.
var url = '<?php echo JURI::base();?>index.php?option=com_test&task=getselectmode&selectedid='+$('parent_question').value;
var params ={method: 'post',update:'test'};
var myAjax = new Ajax(url, params);
myAjax.request();
我的概率是,有没有设置Ajax请求的onComplete时间。 我已经在上面code,但没有发生设置如下图所示。
My prob is that, is there any to set onComplete event of the ajax request. i have set it as below on above code but nothing happen.
onComplete: function(response) { alert('Response: ' + response); }
可否请您提供如何使用mootools的1.1 ??使用Ajax全code
Can you please provide full code of how to use ajax using mootools 1.1 ??
在此先感谢
推荐答案
只需添加的onComplete到params对象,无需seaprately添加事件。此外,您还可以使用this.response.text。它都可以看起来更密实一点 - 取决于你的preference。如果你不重用对象的计划,只是把它直接和不把它分配给一个变量之一:
just add the onComplete to the params object, no need to add the event seaprately. also, you can use this.response.text. it can all look a bit more compacted - depends on your preference. if you don't plan on reusing the object, just call it direct and don't assign it to a variable either:
new Ajax(url, {
method: "get",
update: $("someelement"),
onComplete: function() {
alert(this.response.text);
}
}).request();
如果你做一些与响应文本,你可能想要删除的更新:位。如果您需要评估的反应(如JavaScript),使用evalResponse:代替的eval(this.response.text)真;. 。也很方便 - evalScripts:真|如果你想要做的从服务器端的东西一起响应假
if you do something with the response text, you may want to remove the update: bit. if you need to evaluate the response (as javascript), use evalResponse: true instead of eval(this.response.text);. also handy - evalScripts: true|false if you want to do something from the server side along with the response.
这篇关于在使用Joomla的mootools设置Ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!