Permalink
Browse files

Don't try and convert data for 204 No Content responses. Fixes #13292…

…. Fixes #13261.
  • Loading branch information...
1 parent 21af3a9 commit eb47553eeac58861bcefac063c0e03e161b4d52c @byroot byroot committed with jaubourg Jan 24, 2013
Showing with 33 additions and 3 deletions.
  1. +8 −3 src/ajax.js
  2. +5 −0 test/data/nocontent.php
  3. +20 −0 test/unit/ajax.js
View
@@ -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;
View
@@ -0,0 +1,5 @@
+<?php
+
+header('HTTP/1.0 204 No Content');
+
+?>
View
@@ -1498,6 +1498,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()

0 comments on commit eb47553

Please sign in to comment.