diff options
-rw-r--r-- | src/ajax.js | 11 | ||||
-rw-r--r-- | test/data/nocontent.php | 5 | ||||
-rw-r--r-- | test/unit/ajax.js | 20 |
3 files changed, 33 insertions, 3 deletions
diff --git a/src/ajax.js b/src/ajax.js index 6dd34a732..a7508e972 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -624,12 +624,17 @@ jQuery.extend({ } } - // If not modified - if ( status === 304 ) { + // if no content + if ( status === 204 ) { + isSuccess = true; + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { isSuccess = true; statusText = "notmodified"; - // If we have data + // If we have data, let's convert it } else { isSuccess = ajaxConvert( s, response ); statusText = isSuccess.state; diff --git a/test/data/nocontent.php b/test/data/nocontent.php new file mode 100644 index 000000000..9c8431bd7 --- /dev/null +++ b/test/data/nocontent.php @@ -0,0 +1,5 @@ +<?php + +header('HTTP/1.0 204 No Content'); + +?>
\ No newline at end of file diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 7bc48c997..e5e82f977 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1456,6 +1456,26 @@ module( "ajax", { strictEqual( ajaxXML.find("tab").length, 3, "Parsed node was added properly" ); } }); + + ajaxTest( "#13292 - jQuery.ajax() - converter is bypassed for 204 requests", 3, { + url: "data/nocontent.php", + dataType: "testing", + converters: { + "* testing": function() { + throw "converter was called"; + } + }, + success: function( data, status, jqXHR ) { + strictEqual( jqXHR.status, 204, "status code is 204" ); + strictEqual( status, "nocontent", "status text is 'nocontent'" ); + strictEqual( data, undefined, "data is undefined" ); + }, + error: function( _, status, error ) { + ok( false, "error" ); + strictEqual( status, "parsererror", "Parser Error" ); + strictEqual( error, "converter was called", "Converter was called" ); + } + }); //----------- jQuery.ajaxPrefilter() |