Stop scope until change input value

Asked

Viewed 44 times

0

I have a form, where a captcha is valid via json:

$.getJSON('?verify&string=' + captcha, function( content ){
    if(content.comparation){
       $("#tokenCaptcha").val(content.token);
    }else{
        complete = false;
    }
});

After a few lines, the function returns true or false to send the form or not. The fact is that it takes a long time to change the value. So much so that the form is sent before the value is modified. I did a test with a value Alert, it took about 1 second to give the token Alert.

  • How are you starting this .getJSON? and what do you want to change? I don’t understand what you want to do when you say "Stop scoping"...

  • He is making an "asynchronous" request, of course, but the execution of the scope is also asynchronous. Even without finishing the request .getJSON the scope continues running, and consequently the form is sent without changing the parameter I want (token)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.