gpt4 book ai didi

jquery - 验证码:验证困难

转载 作者:行者123 更新时间:2023-12-01 03:20:08 27 4
gpt4 key购买 nike

我正在尝试实现验证码。我正在使用 jquery (ajax) 调用验证脚本 (http://www.google.com/recaptcha/api/verify)。这将数据类型限制为 JSONP,Google 拒绝所有其他数据类型。

问题是谷歌验证返回字符串如下:真的成功

或者错误的'错误消息'

这会导致 jquery 端出现解析错误...有谁知道如何解决这个问题或最坏的情况,即使存在解析错误也能检索响应文本?

以下是我的ajax请求。我添加了完整和错误函数进行测试。

$("#verifyCaptcha").click(function(){
var chal = Recaptcha.get_challenge();
var resp = Recaptcha.get_response();
$.ajax({
url: "http://www.google.com/recaptcha/api/verify",
type: "GET",
data: {
privatekey: "MyKey",
remoteip: "172.29.129.133",
challenge: chal,
response: resp
},
//dataType: 'jsonp',
success: function(output){
output = output.split('/n');
console.log(output[0] + '**' + output[1]);
if(output[0].toLowerCase() == 'true')
$("#recaptcha_result").html('Succes: form will be sent.');
else
$("#recaptcha_result").html('Failed: form will NOT be sent.');
},
complete:function (xhr, status) {
if (status === 'error' || !xhr.responseText)
console.log('an error occured');
else
var data = xhr.responseText;
},
error: function(request, status, error)
{
if(request.responseText == 'success')
$("#recaptcha_result").html('Succes: form will be sent.');
else
$("#recaptcha_result").html('Failed: form will NOT be sent.');
console.log(request.responseText + '**'+status + "**"+error);
}
});

});

最佳答案

我认为是由于请求类型的原因,其AJAX和跨域请求无效。

查看此处了解更多信息:

Verifying RECAPTCHA with jQuery

关于jquery - 验证码:验证困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10801779/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com