Jump to content

Ajax Captcha


x_maras

Recommended Posts

Hi,

 

I am trying to learn ajax so I decided to make a simple captcha.

The good thing is that it works the bad thing that it has an one click late response... I will try to explain you what I mean with one click late response.

 

I have a a form and instead of submit button I have a normal button which onclick calls 2 functions.

<input name="submit" value="Eisagwgi" type="button" onclick="testCaptcha(); calculateLatLng();"/> 

The first checks the captcha and if its right then stores '1' in a global var.

The second one checks this global variable (and some other checks and calculations) and if the value is '1' then inserts some data in a database.

else shows a message next to the captcha box.

 

So when I press this button and  the captcha is wrong it shows the false message. If the the inserted captcha is right in the first click shows the false message  and if I click again the button shows the correct message and continue with the database thing.

 

I would really appreciate it if someone could explain me why this happens.

I could also post my code (it is not a secret) but I didn't want to make the already big post, bigger.

 

Thank you in advance,

 

Dinos

Link to comment
Share on other sites

If the second function is relying on the first resolving, you may need to stall the second one's call.

 

onclick="a(); setTimeout(function(){b();},1000);"

 

Will run the first function, which will update globals, etc, and then, one second later, run the other. It could just be that your first function is taking too long to process.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.