cloudant post 错误请求
cloudant post bad request
我正在尝试 post json 对象到 cloudant 数据库中。为什么我会收到“400 错误请求”响应?
pos = {
'lat': position.coords.latitude,
'long' : position.coords.longitude
};
$.ajax({
type: "POST",
url: 'http://03353b2e-7d68-462a-b0ab-d5feeae889fd-bluemix.cloudant.com/locations',
data: pos,
contentType: "application/json",
dataType: 'json'
});
使用
修复
data: JSON.stringify(pos)
感谢 Nico O 的回答
我正在尝试 post json 对象到 cloudant 数据库中。为什么我会收到“400 错误请求”响应?
pos = {
'lat': position.coords.latitude,
'long' : position.coords.longitude
};
$.ajax({
type: "POST",
url: 'http://03353b2e-7d68-462a-b0ab-d5feeae889fd-bluemix.cloudant.com/locations',
data: pos,
contentType: "application/json",
dataType: 'json'
});
使用
修复data: JSON.stringify(pos)
感谢 Nico O 的回答