javascript – jquery.ajax多数据检索

前端之家收集整理的这篇文章主要介绍了javascript – jquery.ajax多数据检索前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

当我使用这段代码时,我只设法检索recaptcha_response_field.如果我删除recaptcha_response_field,我会检索recaptcha_challenge_field.但是,我无法同时检索这两个.
我只设法发送1个数据.

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;
}
最佳答案
你写了这行数据:“recaptcha_response_field =”responseField“& recaptcha_challenge_field =”challengeField,错了.

你可以试试这个:

$.ajax({
   type: "POST",url: "some.PHP",data: { name: "John",location: "Boston" }
 }).done(function( msg ) {
          alert( "Data Saved: " + msg );
     });

要么
          data:{recaptcha_response_field:responseField,recaptcha_challenge_field:challengeField

谢谢,
Chintu

猜你在找的jQuery相关文章