jQuery:在错误函数中使用时,getResponseHeader在IE中不起作用

我正在使用jQuery 1.7.1。 以及Ajax Form插件 ,最新版本。 当我执行Ajax请求时,例如:

$('form').ajaxForm ( { success: function ( data ) { alert ( data.responseText ); }, error: function ( data, status, error ) { alert ( data.getResponseHeader('Content-type') ); } } ); 

如果请求返回错误,IE(IE9,在我的情况下)将始终返回undefined的Content-type标头或任何其他标头。 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中绕过这种行为的任何想法?

我有类似的问题。 由于某种原因,除非您在使用GET时未在静态页面上明确要求,否则IE将不会检索头部。 将ajax类型更改为“HEAD”而不是GET或POST,它应该拉出响应头。