#13923 closed bug (wontfix)
statusCode can not be initialized as an ajax option in $.ajaxPrefilter
Reported by: | thomasrosshallock | Owned by: | jaubourg |
---|---|---|---|
Priority: | blocker | Milestone: | None |
Component: | ajax | Version: | 2.0.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Here is a demonstration of this issue: http://jsfiddle.net/antialias/BbQHr/
Change History (3)
comment:1 Changed 10 years ago by
Component: | unfiled → ajax |
---|---|
Owner: | set to jaubourg |
Priority: | undecided → blocker |
Status: | new → assigned |
comment:2 Changed 10 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
OK, I've looked into this and it's quite tricky to fix because we have some nasty interaction with jqXHR.statusCode()
so what I'd recommend is to actually use jqXHR.statusCode()
instead of manipulating the option directly:
$.ajaxPrefilter( function( _, jqXHR ) { jqXHR.statusCode( { 404: function() { // Your code here } } ); } );
comment:3 Changed 9 years ago by
} else if ( type === "error" ) { complete( // file protocol always yields status 0, assume 404 xhr.status || 404, xhr.statusText );
And this is what you get
Note: See
TracTickets for help on using
tickets.
Confirmed in both 1.x and 2.x.