Tag: wcfrest

jQuery .ajax()POST请求在RESTful WCF上抛出405(方法不允许)

我正在向RESTFUL WCF服务应用程序发送一个post请求。 我能够通过Fiddler成功发送POST请求。 但是,当我通过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: […]