GET-ting 数据有效,但是我无法通过单击按钮更新数据,并收到 501(未实现)错误。我相信它处理了启用 CORS 的需要。请看我的小提琴。提前致谢!
var requestSettings = {
url: "http://services.odata.org/V3/(S(ettihtez1pypsghekhjamb1u))/OData/OData.svc/Products(" + key + ")",
method: "POST",
headers: {
"X-Http-Method": "PATCH",
'accept': "application/json;odata=verbose"
},
'contentType': "application/json; charset=utf-8", //content-length not required
datatype: 'json',
data: JSON.stringify(values),
success: function updateSuccess() {
deferred.resolve();
alert("successful update");
},
error: function updateError() {
deferred.reject();
alert("un-successful update");
}
};
$.ajax(requestSettings);
我在这里有一个 JSFiddle: https ://jsfiddle.net/jf713jf/ybLg1b4h/4/