[英]Ajax Webapi Post request for crossdomain in IE8
I am trying to access a WebAPI (in the same server but different IP). 我正在尝试访问WebAPI(在同一服务器上,但使用不同的IP)。 It works like a charm in IE 10 .
在IE 10中它就像一个魅力。 But in IE 8 it goes worse.
但是在IE 8中,情况变得更糟。 I have included $.support.cors=true and also included the jQuery.XDomainRequest.js which I got from https://github.com/MoonScript/jQuery-ajaxTransport-DomainRequest/blob/master/jQuery.XDomainRequest.js
我包含了$ .support.cors = true,还包含了我从https://github.com/MoonScript/jQuery-ajaxTransport-DomainRequest/blob/master/jQuery.XDomainRequest.js获得的jQuery.XDomainRequest.js。
For the GET request it is working, but for the post its throwing out error. 对于GET请求,它正在工作,但是对于发布,它的抛出错误。 I learned that for POSt content type should be text/plain.
我了解到,对于POSt,内容类型应为text / plain。 I tried to send my data as a plain text, probably the server is not parsing it properly.
我试图将数据以纯文本格式发送,可能服务器未正确解析它。 I also tried jsonp as well, but didn't work I am putting down my webapi call .
我也尝试了jsonp,但没有成功,因此我拒绝了webapi呼叫。 Please suggest on how can I get this working.
请提出有关如何使它工作的建议。 Thanks a lot .
非常感谢 。
function Authenticate() {
var UserInfoRequest = {
Email: $("#txtEmail").val(), SubDomain: subDomainName
};
//UserInfoRequest ="Email="+$("#txtEmail").val()+"&SubDomain="+subDomainName;
$.ajax({
url: defaultAPIurl + "Login/UserExistOrDualRole" ,
type: "POST",
dataType: 'json',
data: UserInfoRequest ,
success: function (data) {
//do something
},
error: function (data) {
Showerror();
return;
}
});
return false;
}
ASP.NET WEB API support CROS need extra library. ASP.NET WEB API支持CROS需要额外的库。 Check this post: CORS support for ASP.NET Web API
检查这篇文章: CORS支持ASP.NET Web API
Modified your project as this post written,it's will be working. 撰写本文后,修改了您的项目,该项目可以正常工作。
tips:The two library at their NightBuild Nuget server when I used it. 提示:当我使用它们时,两个库位于其NightBuild Nuget服务器上 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.