【发布时间】:2014-06-19 08:08:00
【问题描述】:
我正在尝试使用骨干集合的 create 方法将一些数据发布到服务器,如下所示:
this.collection.create(modelData,
{
wait:true,
contentType:"application/x-www-form-urlencoded"
});
这里的模型数据包含格式良好的 JSON 对象。问题是发布请求总是被取消。发送的数据是requestpayload的形式。
使用一些 REST 客户端 我可以轻松发布,因为它使用 formData 而不是 requestPayload 发送数据。
有接受者吗?
编辑
这是我在网络控制台中得到的:
Request URL:http://myendpointurlhere.com/
Request Headers CAUTION: Provisional headers are shown.
Accept:application/json, text/javascript, */*; q=0.01
Cache-Control:no-cache
Content-Type:application/x-www-form-urlencoded
Origin:http://localhost:8888
Pragma:no-cache
Referer:http://localhost:8888/case/12345
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36
Form Dataview sourceview URL encoded
model:{"startDate":"19/5/2014","acute":"true","terminal":"true","comment":"","name":"Hypothyroidism","caseId":"4872585904914432"}
编辑 2
出于某种原因,这对我有用。让我知道您对此的看法:
this.collection.create({},
{
data:modelData,
wait:true,
emulateJSON:true
});
【问题讨论】:
标签: javascript jquery http rest backbone.js