I am using jQuery 1.7.1. along with the Ajax Form plugin, latest version available. When I do an Ajax request, such as:
$('form').ajaxForm (
{
success: function ( data )
{
alert ( data.responseText );
},
error: function ( data, status, error )
{
alert ( data.getResponseHeader('Content-type') );
}
}
);
If the request returns an error, IE (IE9, in my case) will always return undefined for the Content-type header or any other header for that matter. The data.responseText property also returns null. This is not the case for Gecko or Webkit browsers.
These are an example of the response headers that the Ajax request is returning:
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
Any idea on how to circumvent this behavior in IE?
I had a similar problem. For some reason IE won't retrieve the head unless you explicitly ask for it on static pages that haven't changed when you use GET. Change the ajax type to "HEAD" instead of GET or POST and it should pull the response headers.