For Request.HTML the success function is defined as.....
onSuccess(responseTree, responseElements, responseHTML, responseJavaScript)
so you are asking in your example if response.response is equal to the
string "ok" but the position of the argument, in position 1 indicates that
in your case response.response will be equal to an element, not the response
string.
so if you had
onSuccess: function(tree, responseElements, responseHTML){
if (responseHTML == 'ok') {
alert('ok');
}
then maybe that will work?
Steve
_____
From: limodou [mailto:[email protected]]
Sent: Thursday, 10 September 2009 1:31 AM
To: [email protected]
Subject: [Moo] Re: mootools 1.2 - set('send', ... Not working evalResponse
or EvalScripts
On Fri, Jul 24, 2009 at 7:33 AM, paulocamboim<[email protected]> wrote:
>
> It worked using Resquest HTML. I will post the code in case someone
> need it..
> thanks Fabio..
>
> // sFormName => the form you want to send
> // sContentShow => the element that you want load the response...
>
> $(sFormName).addEvent('submit', function(e){
> // Prevents the default submit event from loading a new page...
> e.stop();
> var url = $(sFormName).action;
>
> var req = new Request.HTML({
> url: $(sFormName).action,
> update: $(sContentShow),
> onComplete: function(response) {
> ...........
> }
> },
> onSuccess: function(tree, response){
> ..............
> }
> }).post($(sFormName));
> });
>
>
I also encountered this problem, evalResponse can't work even in
Request.HTML
window.addEvent('domready', function() {
var form_send = function(el){
el.addEvent('submit', function(e) {
//Prevents the default submit event from loading a new page.
e.stop();
var b = this.getElement('input[type=submit]');
var div = this.getParent();
b.set('disabled', true)
var req = new Request.HTML({
url: el.action,
evalResponse: true,
onComplete: function(response) {
b.set('disabled', false);
},
onSuccess: function(tree, response){
if (response.response == 'ok') {
alert('ok');
}
}
}).post(el);
});
};
form_send($('form'));
});
The response is:
{"response": "ok"}
but
if (response.response == 'ok') {
alert('ok');
}
This code line will not be executed at all.
Is this a bug?
--
I like python!
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/
UliWeb <<simple web framework>>: http://uliwebproject.appspot.com
My Blog: http://hi.baidu.com/limodou