我创建了一个 wcf 并在我的机器上本地运行。在同一个项目中,我创建了一个使用 ajax 调用此 wcf Web 服务的 html 页面。
$.ajax({
type: "POST",
url: "wbsvc.svc/calendar",
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
processData: false,
success: function (msg) {
var data = msg.d;
console.log(data);
},
error: function (msg) {
console.log(msg);
}
});
calendar 是 webservice 中的方法。错误是
Failed to load resource: the server responded with a status of 400 (Bad Request) in wcf using ajax http://localhost:65029/wbsvc.svc/calendar?callback=jQuery110108707461392041296_1379052209564
我在这里缺少什么。
接口是
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
Model.calenderinfo[] calendar();