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