[英]Ajax request collapsing multi-level JSON object?
Im sending data through JQuery
AJAX
to a python backend server
. 我通过JQuery
AJAX
将数据发送到python backend server
。 When I send the data it changes the object to a different format. 当我发送数据时,它将对象更改为其他格式。 Is there a way of stopping this? 有办法阻止这种情况吗? I've looked online but i'm not 100% whats going on. 我已经上网了,但我不是100%发生了什么。
Example of data im sending through the request: 通过请求发送数据的示例:
data:{
name:"test",
products:[
{ name: "test_product", id: 1 },
{ name: "test product2", id: 2 }
],
session_id:"blablabla",
}
How it appears when it comes into the server: 它进入服务器时的外观:
{
"name":"test",
"products[0][name]":"test_product",
"products[0][id]":"1",
"products[1][name]":"test_product2",
"products[1][id]":"2",
"session_id":"blablabla",
}
Data was being sent as form data because i didn't include 数据被作为表单数据发送,因为我没有包括
contentType: 'application/json'
In the ajax call. 在ajax中调用。 Thanks bruno :) 谢谢布鲁诺:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.