我正在使用Jquery DataTable。并使用AJAX调用(跨域请求)这样得到的数据:无法在POST请求期间将内容类型设置到IE 8中的ajax请求标头上
ajax: {
url: url,
type: 'POST',
dataType: 'json',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
}
这是头如何查找在这个请求IE 8
Key Value
Request POST /api/data HTTP/1.1
Accept */*
Origin http://localhost:5000
Accept-Language en-US
Accept-Encoding gzip, deflate
User-Agent Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)
Host localhost:5555
Content-Length 3647
DNT 1
Connection Keep-Alive
Cache-Control no-cache
的Jquery DataTable自动将内容发布到服务器。但当请求通过IE 8发送时,服务器没有收到任何数据中的HttpContext.Current.Request.Form
对象。我使用下面的代码来读取服务器发布的数据。
var formData = HttpContext.Current.Request.Form;
var direction = formData["order[0][dir]"];
var draw = Convert.ToInt32(formData["draw"]);
var length = Convert.ToInt32(formData["length"]);
var start = Convert.ToInt32(formData["start"]);
如果我通过chrome或FireFox发布请求,我会在服务器上获取数据。 当请求正在通过IE 8内容类型头未设置时。我认为这是数据在服务器端不可用的原因。请帮忙!!
感谢您的回复。我已经尝试设置contentType,但看起来像IE 8不会发送此信息。检查这个链接点没有4. http://blogs.msdn.com/b/ieinternals/archive/2010/05/13/xdomainrequest-restrictions-limitations-and-workarounds.aspx – SharpCoder 2014-09-30 10:16:34
它是跨域吗? – RichieAHB 2014-09-30 10:21:12
是的这是跨域请求 – SharpCoder 2014-09-30 10:24:45