【发布时间】:2012-05-25 19:45:03
【问题描述】:
我正在使用 jQuery 1.7.1。连同Ajax Form plugin,最新版本可用。当我执行 Ajax 请求时,例如:
$('form').ajaxForm (
{
success: function ( data )
{
alert ( data.responseText );
},
error: function ( data, status, error )
{
alert ( data.getResponseHeader('Content-type') );
}
}
);
如果请求返回错误,IE(在我的例子中是 IE9)将始终为 Content-type 标头或任何其他标头返回 undefined。 data.responseText 属性也返回 null。 Gecko 或 Webkit 浏览器并非如此。
这些是 Ajax 请求返回的响应标头的示例:
Response HTTP/1.1 400 Bad Request
Date Fri, 18 May 2012 08:15:32 GMT
Server Apache/2.2.14 (Ubuntu)
X-Powered-By PHP/5.3.2-1ubuntu4.15
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Connection close
Content-Type text/html
知道如何在 IE 中规避这种行为吗?
【问题讨论】:
标签: jquery internet-explorer header ajaxform