简体   繁体   English

无法通过Ajax发布数组

[英]Unable to post array via ajax

I am trying to post an array created in js to a php page 我正在尝试将在js中创建的数组发布到php页面

 var newEventArray = new Array();  
        newEventArray["title"] = title;
        newEventArray["description"] = description;
        newEventArray["type"] = type;
        newEventArray["visibility"] = visibility;
        newEventArray["priority"] = priority;
        newEventArray["start"] = start;
        newEventArray["end"] = end;
        newEventArray["allDay"] = allDay;

        $.ajax({
            type: "POST",
            url: "includes/processor.php",
            data: {request: 'createevent',
                requestarray: newEventArray},

            dataType: "json",
            success: function(data) {

            },
            error: function(data) {
            }
        });

but i am unable to get the array at the php end. 但是我无法在php端获取数组。 The array doesnt show when checked with firebug 用firebug检查时不显示数组

JavaScript Arrays are designed to hold an ordered sequence of items with integer keys. JavaScript数组设计为使用整数键保存项目的有序序列。 When jQuery converts a data structure into Form URL Encoded data and encounters an array, it will iterate over those integer keys and not over named keys. 当jQuery将数据结构转换为Form URL Encoded数据并遇到数组时,它将遍历那些整数键而不是命名键。

Use an Object if you want to have named keys. 如果要命名键,请使用对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM