jQuery的POST不发送内容类型上的IE10 [英] jQuery POST not sending Content-Type on IE10
问题描述
我使用jQuery 1.9.1和Internet Explorer版本10.0.9200.16686,更新版本10.0.9(KB2870699),在Windows 7 64位。
I'm using jQuery 1.9.1 and Internet Explorer Version 10.0.9200.16686, Update Version 10.0.9 (KB2870699), on Windows 7 64-bit.
在使用$就到邮政,Content-Type头不被发送。它工作正常,在Chrome和其他浏览器,我相信用在IE10之前精细工作,所以我怀疑某些更新IE10引起的问题。
When using $.ajax to POST, the Content-Type header is not being sent. It works fine in Chrome and other browsers, and I believe used to work fine before on IE10 so I suspect some update to IE10 caused an issue.
我还可以手动创建一个XMLHtt prequest并发送一个请求,所以我假设它必须是jQuery的一个错误,就是真正的问题?我尝试升级到1.10.2,但得到了同样的问题。
I can also manually create an XMLHttpRequest and send a request, so I'm assuming it must be a bug in jQuery that's the real issue? I tried upgrading to 1.10.2, but get the same problem.
我有集的contentType使用 $ ajaxSetup
:
I have the contentType set using $.ajaxSetup
:
$.ajaxSetup({
contentType: 'application/json; charset=utf-8',
context: document.body,
dataType: 'json',
accepts: 'application/json',
processdata: true,
cache: false,
crossDomain: true,
xhrFields: { withCredentials: true }
});
我也试着显式地设置作为 $。阿贾克斯
选项的一部分。
var options = {
url: basePath + 'login',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({
UserName: username,
Password: password,
RememberMe: rememberMe || false
})
};
return $.ajax(options).then(...);
任何想法如何解决这将是AP preciated。
Any ideas how to fix it will be appreciated.
请注意:我们在最初使用CORS,故名为 xhrFields
和跨域
设置的原因,但目前就因为与IE8和IE9和问题上有着相同的域名托管一切 XDomainRequest
。
Note: we were initially using CORS, hence the reason for the xhrFields
and crossDomain
settings, but are currently hosting everything on the same domain because of issues with IE8 and IE9 and XDomainRequest
.
推荐答案
看来,我们还是有的 xdr.js 脚本包括启用CORS的IE浏览器,这是导致此问题。
It appears that we still had the xdr.js script included to enable CORS on IE, which was causing this issue.
这篇关于jQuery的POST不发送内容类型上的IE10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!