id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blocking	blockedby
11426	jQuery.ajax() always fails when requesting JPG images in IE	leilers@…		"* jQuery version: all (verified bug exists in 1.7.1)
* Affected browsers: IE (tested IE6-9). Doesn't happen in any other browser.

$.ajax() executes the error callback instead of the success callback when a request is made for a jpeg in IE.

The exception is:
'Could not complete the operation due to error c00ce514.'

Minimal repro case URL:
http://dl.dropbox.com/u/45268548/jquerybug/test.htm

The exception is thrown in the ajaxTransport definition for XHR, in the callback function. It is caused by attempting to access XmlHttpRequest.responseText when the response is binary JPEG data (doesn't affect GIF or PNG). This is line 8148 of jquery-1.7.1.js:

{{{
status = xhr.status;
responseHeaders = xhr.getAllResponseHeaders();
responses = {};
xml = xhr.responseXML;

// Construct response list
if ( xml && xml.documentElement /* #4958 */ ) {
    responses.xml = xml;
}
responses.text = xhr.responseText; //IE exception thrown here

// Firefox throws an exception when accessing
// statusText for faulty cross-domain requests
try {
    statusText = xhr.statusText;
} catch( e ) {
    // We normalize with Webkit giving an empty statusText
    statusText = """";
}
}}}

The solution I'd recommend is to simply wrap the call to xhr.responseText with a try/catch, where the catch block sets responses.text to null. While this wouldn't fix the inability to access the binary data (IE's javascript doesn't seem to be able handle the binary data from responseBody in general), it would at least behave correctly in other regards- calling the success handler, and allowing access to the response headers (which can be very useful for transmitting metadata along with images). 
"	bug	closed	low	1.7.2	ajax	1.7.1	fixed				
