You're doing it wrong.

The `onComplete` event is there for a reason, it'll fire once the request 
finishes. Which means that you actually want to do `return result;` inside of 
this callback function.

O.

On 2010-11-26, at 18:46, machadoug wrote:

> Greetings,
> 
> For some reason the onComplete takes too long to execute.
> 
> The Code is very simple:
> this.setHandler('sicaptcha',
>       function (value) {
>               var result;
>               var url = 'plugins/content/captcha_systems/securImage2/
> securimage_json.php';
>               var jSonRequest = new Json.Remote(url, {onComplete:
> function(response){
>                               console.log('response.action: 
> '+response.action);
>                               if(response.action == 'success'){
>                                       result = true;
>                                       return true;
>                               }else{
>                                       result = false;
>                                       return false;
>                               }
>                       }
>               }).send(Json.toString({'captcha_code':value}));
>               console.log('result:'+result);
>               return result;
>       }
> );
> 
> I've been testing with FireBug and the code inside the onComplete is
> being executed last. Please follow the link below to see a FireBug
> screnshot:
> http://ideal.fok.com.br/images/Screenshot-Firebug.png
> 
> Thanks in advanced for your help.

Reply via email to