Javascript 从AJAX接收序列化数组数据以处理php页面

Javascript 从AJAX接收序列化数组数据以处理php页面,javascript,php,jquery,html,json,Javascript,Php,Jquery,Html,Json,在这段代码中,我已将表单值传递给process.php,但我无法在process.php中接收发布的值,有人建议我在process.php中接收数组值吗 $('#submit').click(function() { var data = JSON.stringify($("#players_form").serializeArray()); alert(data); $.ajax({ // Send the credential values to another checker.php us

在这段代码中,我已将表单值传递给process.php,但我无法在process.php中接收发布的值,有人建议我在process.php中接收数组值吗

$('#submit').click(function()
{
var data = JSON.stringify($("#players_form").serializeArray());
alert(data);
$.ajax({ // Send the credential values to another checker.php using Ajax in POST menthod
        type : 'POST',
        data : data,
        url  : 'process.php',
        success: function(responseText)
       {
            if(responseText == 1)
            {
            alert("Sucess");
            }
        }

您可以用两种不同的方式使用serializeArray方法。
var data=JSON.stringify($(“form”).serializeArray()


var data=JSON.stringify($(“:input”).serializeArray()

试试这个ajax脚本,我确保它能正常工作

$(文档).ready(函数(){
$(“#提交”)。单击(函数(){
var post_data=$(“#玩家_表单”).serializeArray();
$.ajax({
键入:“POST”,
数据:post_数据,
url:'process.php',
成功:函数(responseText){
console.log(responseText);
if(responseText==1){
警惕(“成功”);
}
}
})
})
});将数据替换为

<form id="players_form"  >
<input type=" text" name="main_name[]" value="">
<input type=" text" name="main_name[]" value="">
<input type=" text" name="main_name[]" value="">
<input type=" text" name="main_name[]" value="">
<input type=" text" name="main_name[]" value="">
<input type=" text" name="sub_name[]" value="">
<input type=" text" name="sub_name[]" value="">
<input type=" text" name="sub_name[]" value="">
<input type=" text" name="sub_name[]" value="">
<input type=" text" name="sub_name[]" value="">
<input type="button" value="Submit" id="submit">
</form>
var data=$(“#玩家_形式”).serializeArray(); 提出你的要求作为

var data = $("#players_form").serializeArray(); 数据类型:“JSON”, 数据:{玩家:数据}, 并在服务器中处理数据,如下所示

dataType : 'JSON', data : {players:data},
$player=$_POST['players'];我想在PHP页面中收到我理解你的问题。你发送了错误的数据。显然,对象在jQuery中转换为JSON函数,因此可以使用。它只是在process.php中作为数组重新运行,而不是值arrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray $player = $_POST['players'];