#9808 closed bug (invalid)
.ajax() calls don't catch 401 erros
Reported by: | mattelacchiato | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | ajax | Version: | 1.6.2 |
Keywords: | Cc: | jaubourg | |
Blocked by: | Blocking: |
Description
Hi,
when calling an url which will return a 401 error, .ajax() doesn't catch this error:
$.ajax({ url: "http://url.with.401.error", dataType: 'script', statusCode: { 401: function() { alert("foo"); } }, error: function(xhr, status, errorThrown) { alert("bar"); } });
Neither "foo", nor "bar" alerts are shown.
Change History (6)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Cc: | jaubourg added |
---|---|
Component: | unfiled → ajax |
Priority: | undecided → low |
Status: | new → open |
Confirmed. @jaubourg, could you take a further look into the cause?
comment:3 Changed 12 years ago by
Milestone: | None → 1.next |
---|
comment:4 Changed 12 years ago by
Just a wild guess here... the request is cross-domain?
Because same-domain seems to work all-right: http://www.bennadel.com/blog/2228-Some-Thoughts-On-Handling-401-Unauthorized-Errors-With-jQuery.htm
Cross-domain script and jsonp requests do NOT handle errors as documented in the API docs.
comment:5 Changed 12 years ago by
You're right, it's a cross-domain request. Sorry for not reading the docs as I should... :-(
comment:6 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | open → closed |
Note: See
TracTickets for help on using
tickets.
Just figured out now, that
is a major part of this bug. When commenting this out, it will alert "bar" and status is "0". But status should be "401".