1
我正在使用跨域jQuery ajax调用我的WCF web服务。我正在使用CORS的方法,但是错误块并不适合我。当我尝试jsonp方法时,它正在发射。请完成代码。跨域错误处理和WCF
CORS:
function faultCLick() {
$.support.cors = true;
$.ajax({
url: "http://mydomain:84/AuthService.svc/ErrorHandling",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function res(msg) {
jsonpTest = msg;
alert("inside success ");
},
error: function (message) { // not firing
debugger;
var jsonFault = JSON.parse(message.responseText);
alert(jsonFault.Message);
}
});
}
服务: -
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "ErrorHandling")]
string ErrorHandling();
感谢。