jQuery POST一个像这样的对象

时间:2014-05-23 03:27:06

标签: jquery django post

如何使用jquery的POST

发送此字段
"geo": {
        "coordinates": [
              56.3561,
              25.3392
        ],
        "type": "Point"
}

...

data: {geo:{"coordinates": [56.3561,25.3392],"type": "Point"}} 

结果为String or unicode input unrecognized as WKT EWKT, and HEXEWKB

1 个答案:

答案 0 :(得分:2)

您需要先将JSON对象转换为序列化字符串。

var jsonObject = {"geo": {
    "coordinates": [
          56.3561,
          25.3392
    ],
    "type": "Point"
}}

然后:

data: JSON.stringify(jsonObject)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify