i am using new to prototype and using its ajax functionality but not abl开发者_运维知识库e to set the values to return type my code is
var captchaRequest = new Ajax.Request('http://www.example.com/captcha/validate.php', {
parameters: "captcha_code="+captcha_code,
onSuccess: function(result) {
if(result.responseText == 'true') {
return true;
} else {
return false;
}
alert('in ajax response');
}
});
alert('after ajax')
what i want to do is execute some functionality after ajax call is complete and but my second alert which is 'after ajax' is getting executed before 'in ajax response'. I want to use code result from ajax response. please help.
Thank you, pankaj
You do not need to set it to async. Just call your function from within the onsuccess block.
var captchaRequest = new Ajax.Request('http://www.example.com/captcha/validate.php', {
parameters: "captcha_code="+captcha_code,
onSuccess: function(result) {
if(result.responseText == 'true') {
**callMyFunction()**
return true;
} else {
return false;
}
alert('in ajax response');
}
});
alert('after ajax')
精彩评论