Refresh without refreshing the page.

6,624 views
Skip to first unread message

William Paquette

unread,
Jan 10, 2011, 7:06:54 AM1/10/11
to reCAPTCHA
Does anyone know how to get reCAPTCHA to refresh with PHP without
refreshing the page?

Dom Sekotill

unread,
Jan 10, 2011, 3:51:45 PM1/10/11
to reca...@googlegroups.com
On any of the standard themes, press the little cycling arrows button
that says "Get a new challenge" when you hover on it.

If you are making a custom themed captcha get your PHP script to insert
this HTML:

<a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a>

(Source: <http://code.google.com/apis/recaptcha/docs/customization.html>)

William Paquette

unread,
Jan 10, 2011, 4:48:11 PM1/10/11
to reCAPTCHA
Thank you for a response. I don't think I was really clear, I am
working with PHP and Ajax...upon submitting the form, Ajax talks to
the server and determines if the Login and Password is correct. That
same "Validations" page holds the CAPTCHA validation too. What I want
to do is if ANY is incorrect, Ajax reloads the CAPTCHA, right now all
I can get it to do is show the same CAPTCHA challenge...armed with
what you gave me I'm going to try to figure this out...

Welsh_Dwarf

unread,
Jan 11, 2011, 4:29:06 AM1/11/11
to reCAPTCHA
Dom gave you the answer:

Recaptcha.reload()

This reloads the captcha image and gets another challenge ready (since
recaptcha only allows one try per image).

A word from the wise(r):

Use Recaptcha.get_challenge() and Recaptcha.get_response() to pass
the challenge and the response to your server script, tryting to get
the values out of the form fields doesn't work since recaptcha only
seems to update them just before the submit (so after you've
validated).

HTH

David

William Paquette

unread,
Jan 11, 2011, 12:04:17 PM1/11/11
to reCAPTCHA
Thank you both for your response...I was able to get it to do exactly
what I wanted it to. Basically, my solution was to add
onclick="javascript:Recaptcha.reload()" to the submit button. other
than that I pretty much used the example code from this website.
Thank you for all your help...you guys got my wheels turning in the
right direction. I hope that someone will read my post and help them
too. :)

Emma

unread,
Feb 6, 2013, 3:06:17 PM2/6/13
to reca...@googlegroups.com, billy...@gmail.com
Hi William,
Can you please post your code.  I have the same problem as well. I dont want my reCaptcha to refresh the whole page as it is deleting my server side php response on the html page.( I am using Ajax). But I didnt understand your solution properly. Thats the reason I am asking for code.

Can y
Reply all
Reply to author
Forward
0 new messages