Reputation: 2122
I've added a Google ReCaptcha on my website, this is the HTML form as provided by Google:
<script type="text/javascript"
src="http://www.google.com/recaptcha/api/challenge?k=my_public_key">
</script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=my_public_key"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
And this is my jQuery (note that all the values sent by POST are correct, I've checked them all)
$('#captcha_form_btn').live('click', function () {
var challenge = $('#recaptcha_challenge_field').val();
var response = $('#recaptcha_response_field').val();
var remoteip = $('#remoteip').val();
$.ajax({
url:'http://www.google.com/recaptcha/api/verify',
data:'challenge=' + challenge + '&response=' + response + '&remoteip=' + remoteip + '&privatekey=my_private_key',
type:'post',
dataType:'jsonp',
success: function (data) {
console.log(data);
}
});
});
I am using AJAX to verify the client answer to the ReCaptcha, I send client's ip, response, challenge and my private key to get the response from the google API.
However, There's something wrong with API response being received, (I don't exactly know whether is received or not), the firebug javascript console displays a javascript error stating :
ReferenceError: incorrect is not defined
incorrect-captcha-sol
In a google API js file, and when I click on "incorrect-captcha-sol" ... it redirects me to a javascript file with these two lines :
false
incorrect-captcha-sol
I think, this is the response which is supposed to be sent back to the client, as json data, but here, I see that it's involved in a JS error in the API js file.
What's wrong with it?
Upvotes: 0
Views: 2709
Reputation: 95028
In this case, you'll want to use your server as a proxy to make this request so that:
The process will be
Browser -> Your Server -> Google Server -> Your Server -> Browser
Upvotes: 1