在 ajax POST 上传递多个 3D 数组

Passing multiple 3D arrays over ajax POST

我在数据格式化方面遇到了问题。我有几个 3-D 数组(sticklers 数组的数组),我想通过 ajax POST 传递给 PHP 函数。我试过将它们组合成一个对象,然后用 JSON.stringify:

对其进行字符串化
var postFile = '/games/saveMap';
var postObj = {'mapTiles':mapArray,
            'tileRots':rotations,
            'ceilings':ceiling,
            'floors':floor,
            'pitDepth':depth,
            'sections':sectionNames,
            'mapName':$('#mapName').val()
    }
var postData = JSON.stringify(postObj);
$.ajax({
        type: 'POST',
        url: postFile,
        data: postObj,
        success: function(data)
        {
        },
        error: function(jqXHR, textStatus, errorThrown)
        {
        }
});

无论我发送 postObj 还是 postData,我都会收到一个错误,指出对象中所有索引的索引都未定义。我的格式有什么问题? POST 需要什么格式来检测我的索引?

编辑:虽然我在服务器端语法中没有发现问题,但这是抛出 "undefined index" 错误的原因:

$mapName=$_POST['mapName'];
$sectionNames=$_POST['sections'];
$mapArrays=$_POST['mapTiles'];
$rotations=$_POST['tileRots'];
$ceilings=$_POST['ceilings'];
$floors=$_POST['floors'];
$pitDepth=$_POST['pitDepth'];

试试这个:

$.ajax({
    type: 'POST',
    url: '/games/saveMap',
    data: {
        'mapTiles':mapArray,
        'tileRots':rotations,
        'ceilings':ceiling,
        'floors':floor,
        'pitDepth':depth,
        'sections':sectionNames,
        'mapName':$('#mapName').val()
    },
    success: function(data)
    {
    },
    error: function(jqXHR, textStatus, errorThrown)
    {
    }
});

问题是引用 PHP 端的对象。正确的语法结果是

$mapName=$_POST->mapName;
$sectionNames=$_POST->sections;
$mapArrays=$_POST->mapTiles;
$rotations=$_POST->tileRots;
$ceilings=$_POST->ceilings;
$floors=$_POST->floors;
$pitDepth=$_POST->pitDepth;

我本该在 Java/C++ 天记住的事情。