Skip to main content

Bug Tracker

Side navigation

#14207 closed bug (fixed)

Opened July 31, 2013 07:22AM UTC

Closed November 14, 2013 02:01AM UTC

Last modified November 15, 2013 02:01PM UTC

Ajax error defaults to status 404

Reported by: hvrauhal Owned by: dmethvin
Priority: high Milestone: 2.1
Component: ajax Version: 2.0.3
Keywords: xhr-spec Cc: jaubourg
Blocked by: Blocking:
Description

In jquery 2.0.x, ajax requests that fail without ever contacting a server resolve with jqXHR.status 404 and jqXHR.readyState 4. See http://jsbin.com/ejeruf/9 for an example.

In 1.x versions they resolve with jqXHR.status 0 and jqXHR.readyState 0 as expected. See http://jsbin.com/ejeruf/4

The 2.0.x version seems to default to 404 at https://github.com/jquery/jquery/blob/2.0.3/src/ajax/xhr.js#L75 without checking whether the request was local and not crossdomain, as the 1.x version did in https://github.com/jquery/jquery/blob/1.10.2/src/ajax/xhr.js#L156

Attachments (0)
Change History (8)

Changed August 06, 2013 02:32AM UTC by dmethvin comment:1

cc: → jaubourg

@jaubourg, thoughts?

Changed September 05, 2013 12:31PM UTC by hvrauhal comment:2

This buggy behaviour makes jquery 2.0 dangerous to use in modern webapps in wireless environments, where it is essential to know the difference between network errors (that should return with status 0) and real 404's returned by the server.

Changed September 05, 2013 12:42PM UTC by hvrauhal comment:3

I could post a patch that just removes the '

 || 404 
', but that would leave the refactoring of xhr.js halfway regarding how error statuses are handled in file-protocol. The xhrSuccessStatus-mapping does not take the actual request protocol into account neither, though it appears to me that it should.

Changed September 10, 2013 12:49PM UTC by jaubourg comment:4

component: unfiledajax
keywords: → xhr-spec
milestone: None2.next
priority: undecidedhigh
status: newopen

I'm afraid the only actual solution would be to add the local protocol detection code back in. That's the only way we'll be able to differentiate between a 404 and an actual network error.

Let me tag this as xhr-spec. I should really find time to have this dealt with in the XHR spec.

Changed November 08, 2013 02:21PM UTC by jaubourg comment:5

All right, the only solution I see here is to just remove || 404. The only bad side-effect (apart from having a 0 status code for error on local protocols) is a wrong readyState (0 rather than 4) on the jqXHR object. I can live with that.

Changed November 11, 2013 05:13PM UTC by dmethvin comment:6

owner: → dmethvin
status: openassigned

Changed November 14, 2013 02:01AM UTC by Dave Methvin comment:7

resolution: → fixed
status: assignedclosed

ajax: Fix #14207. file protocol returns status 0, see #8605.

Changeset: dce2edb3a615f9de158607c9f8be83809373940e

Changed November 15, 2013 02:01PM UTC by dmethvin comment:8

milestone: 2.next2.1