admin管理员组文章数量:1357225
When I use this code, I only manage to retrieve recaptcha_response_field. If I remove recaptcha_response_field, I retrieve recaptcha_challenge_field. However, I am unable to retrieve the two at the same time. I only managed to send 1 data.
challengeField = $("#recaptcha_challenge_field").val();
responseField = $("#recaptcha_response_field").val();
var html = $.ajax(
{
global: false,
type: "POST",
async: false,
dataType: "html",
data: "recaptcha_response_field=" + responseField + "&recaptcha_challenge_field=" + challengeField,
url: "../ajax.recaptcha.php"
}).responseText;
if(html == "success")
{
$("#captchaStatus").html("Success. Submitting form.");
return true;
}
else
{
$("#captchaStatus").html("Your captcha is incorrect. Please try again");
Recaptcha.reload();
return false;
}
When I use this code, I only manage to retrieve recaptcha_response_field. If I remove recaptcha_response_field, I retrieve recaptcha_challenge_field. However, I am unable to retrieve the two at the same time. I only managed to send 1 data.
challengeField = $("#recaptcha_challenge_field").val();
responseField = $("#recaptcha_response_field").val();
var html = $.ajax(
{
global: false,
type: "POST",
async: false,
dataType: "html",
data: "recaptcha_response_field=" + responseField + "&recaptcha_challenge_field=" + challengeField,
url: "../ajax.recaptcha.php"
}).responseText;
if(html == "success")
{
$("#captchaStatus").html("Success. Submitting form.");
return true;
}
else
{
$("#captchaStatus").html("Your captcha is incorrect. Please try again");
Recaptcha.reload();
return false;
}
Share
Improve this question
edited Dec 20, 2015 at 18:01
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Mar 23, 2010 at 17:09
Guillaume PGuillaume P
511 silver badge2 bronze badges
4 Answers
Reset to default 2you wrote this line data: "recaptcha_response_field=" + responseField + "&recaptcha_challenge_field=" + challengeField,
was wrong.
you can try this:
$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
or
data: {recaptcha_response_field : responseField , recaptcha_challenge_field :challengeField
thanks, Chintu
Try
data: {
recaptcha_response_field: responseField,
recaptcha_challenge_field: challengeField
}
??
What do you mean that $_POST["recaptcha_response_field"]
and $_POST["recaptcha_challenge_field"]
are not both set "inside" ajax.recaptcha.php
.
That's impossible Firebug's Net-Tab shows that the request just works fine.
Did you check your server logs (enable post data logging temporarily )
Maby something like this?
var challengeField = $("#recaptcha_challenge_field").val();
var responseField = $("#recaptcha_response_field").val();
/* Debug */ alert ("Going to send channengeField with value '" + challengeField + "', and responseField with '" + resonseField + "'");
$.post ("../ajax.recaptcha.php", {
recaptcha_response_field: responseField,
recaptcha_challenge_field: challengeField
},
function(data)
{
/* Debug */ alert ("Data Recieved: " + data);
if (data == "success")
{
$("#captchaStatus").html("Success. Submitting form.");
return true;
}
else
{
$("#captchaStatus").html("Your captcha is incorrect. Please try again");
Recaptcha.reload();
return false;
}
});
You can try like this
data: "recaptcha_response_field=" + $("#recaptcha_challenge_field").val() + "&recaptcha_challenge_field=" + ("#recaptcha_response_field").val(),
本文标签: javascriptjqueryajax multiple data retrievalStack Overflow
版权声明:本文标题:javascript - jquery.ajax multiple data retrieval - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744076459a2586838.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论