[英]Converting object into PHP array in JavaScript
When I console.log(myArray); 当我console.log(myArray); it gives me structure below which I think is an object, I want to convert it into a fomrat{like json} that can be passed successfully via Ajax to PHP function
它提供了我认为是对象的结构,我想将其转换为可以通过Ajax成功传递给PHP函数的fomrat {like json}
[Object, Object]
0: Object
color: some value
id: some value
img: some value
name: some value
price: some value
quantity: some value
total: some value
__proto__: Object
1: Object
color: "silver"
id: "3"
img: "Mobile-Huawei-MT7.jpg"
name: " Huawei Honor 6 - H60-L04"
price: "8171"
quantity: "1"
total: "8171"
__proto__: Object
length: 2
__proto__: Array[0]
The log you have is already that json structure. 您拥有的日志已经是该json结构。
See: 看到:
[Object Object]
In this log you can see there are two objects in the array. 在此日志中,您可以看到数组中有两个对象。 In your log I can see you have some key value pairs.
在您的日志中,我可以看到您有一些键值对。
So this 所以这
{key : value}
This is the actual object in the array. 这是数组中的实际对象。
I would say, the log you have is an array which has two objects which is as said above a key value pairs. 我要说的是,您拥有的日志是一个数组,其中包含两个对象,就像上面的键值对所述。
[Object Object]
The above one is just a log representation. 上面只是一个日志表示。 Actual
Object
looks like {}
which can have multiple key value pairs. 实际
Object
看起来像{}
,可以有多个键值对。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.