我正在向RESTFUL WCF服务应用程序发送一个post请求。我能够通过Fiddler成功发送POST请求。jQuery .ajax()POST请求在RESTful WCF上抛出405(方法不允许)
但是我做到这一点通过了jQuery的Ajax方法当函数返回以下Chrome开发控制台:
OPTIONS http://www.example.com/testservice/service1.svc/GetData 405 (Method Not Allowed) jquery.min.js:6
但随后登录后第二:
Object {d: "You entered 10"} testpost.html:16
这告诉我是jQuery发送一个OPTIONS请求,失败,然后发送一个返回预期数据的POST请求。
我的jQuery代码:
$.ajax() {
type: "POST", //GET or POST or PUT or DELETE verb
url: "http://www.example.com/testservice/service1.svc/GetData", // Location of the service
data: '{"value":"10"}', //Data sent to server
contentType:"application/json",
dataType: "json", //Expected data format from server
processdata: false,
success: function (msg) {//On Successfull service call
console.log(msg);
},
error: function (xhr) { console.log(xhr.responseText); } // When Service call fails
});
我使用jQuery 2.0.2版本。
任何帮助,为什么这个错误发生将是一个很大的帮助。