mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Fixes #11426: getting the responseText of an xhr should be tried/caught because of IE's inability to give access to binary data. Unit test added.
This commit is contained in:
parent
014b2a5700
commit
484cea1b56
@ -148,7 +148,13 @@ if ( jQuery.support.ajax ) {
|
|||||||
if ( xml && xml.documentElement /* #4958 */ ) {
|
if ( xml && xml.documentElement /* #4958 */ ) {
|
||||||
responses.xml = xml;
|
responses.xml = xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When requesting binary data, IE6-9 will throw an exception
|
||||||
|
// on any attempt to access responseText (#11426)
|
||||||
|
try {
|
||||||
responses.text = xhr.responseText;
|
responses.text = xhr.responseText;
|
||||||
|
} catch( _ ) {
|
||||||
|
}
|
||||||
|
|
||||||
// Firefox throws an exception when accessing
|
// Firefox throws an exception when accessing
|
||||||
// statusText for faulty cross-domain requests
|
// statusText for faulty cross-domain requests
|
||||||
|
BIN
test/data/1x1.jpg
Normal file
BIN
test/data/1x1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 693 B |
@ -2322,6 +2322,20 @@ test("jQuery.ajax - abort in prefilter", function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "jQuery.ajax - loading binary data shouldn't throw an exception in IE (#11426)", 1, function() {
|
||||||
|
stop();
|
||||||
|
jQuery.ajax( url( "data/1x1.jpg" ), {
|
||||||
|
success: function( data ) {
|
||||||
|
ok( data === undefined || /JFIF/.test( data ) , "success callback reached" );
|
||||||
|
start();
|
||||||
|
},
|
||||||
|
error: function( _, __, error ) {
|
||||||
|
ok( false, "exception thrown: '" + error + "'" );
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("jQuery.ajax - active counter", function() {
|
test("jQuery.ajax - active counter", function() {
|
||||||
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
|
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active );
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user