Skip to content

Instantly share code, notes, and snippets.

@dcherman
Created January 17, 2014 19:00
Show Gist options
  • Select an option

  • Save dcherman/8479347 to your computer and use it in GitHub Desktop.

Select an option

Save dcherman/8479347 to your computer and use it in GitHub Desktop.
$.ajaxPrefilter( "+", function( options, originalOptions, jqXHR ) {
jqXHR.then( null, function( jqXHR, textStatus, errorThrown ) {
var args = arguments;
return $.Deferred( dfr ) {
if ( jqXHR.status === 422 ) {
dfr.resolveWith( this, [ $.parseJSON( jqXHR.responseText ), textStatus, errorThrown ]);
} else {
dfr.resolveWith( this, args )
}
}.promise();
}).promise( jqXHR );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment