Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#5859 closed bug (fixed)

Firefox window.JSON throws uncaught exception when an HTTP Status Code is issued

Reported by: coolaj86 Owned by:
Priority: undecided Milestone: 1.4.1
Component: ajax Version: 1.4
Keywords: Cc:
Blocked by: Blocking:


Firefox has a bug in which it turns the content of non-200 status code XHR responses into an empty string.

In 1.3.2 this was not an issue other than that it returned an empty string for data, but what can you do? There's no workaround I know of for this.

However, in 1.4 jQuery attempts to pass this empty string to window.JSON, which throws an uncaught parseerror and halts js execution.

Perhaps jQuery should first check to see if the string returned is empty (indicating a non-200 response)

Change History (4)

comment:1 Changed 13 years ago by john

Component: unfilledajax
Resolution: fixed
Status: newclosed

comment:2 in reply to:  description Changed 13 years ago by coolaj86

I did want to add that this was only a problem with CORS / XHR2, as far as I can tell. I misspoke as though Firefox has that issue with all non-2XX requests.

comment:3 Changed 13 years ago by scosenz

Hi coolaj86,

Is the CORS/XHR2/non-2xx request issue a known Firefox bug? If so, can you point me to any additional information on it?

I think I'm hitting this bug when doing CORS/XHR2 GET requests over SSL with Cache-Control max-age and etags being used by the server. Whenever such a request should be retrieved from the local cache, the XHR status is 200 and the response is an empty string. However, if I always append a random query string to my request, the cache is not hit, and the response is correct.

Thanks for any help! Steve

comment:4 Changed 13 years ago by scosenz

Ignore my previous comment. If anyone is interested, my bug was being caused by the following:

  1. I viewed a URL in my Firefox browser. Cache-Control headers were returned (max-age), so the URL content along with the returned headers were cached. Since the request was NOT a Cross-Origin request, an Origin header was NOT sent in the request, which meant that the appropriate Cross-Origin headers were NOT sent in the response.
  2. My javascript sends a Cross-Origin XHR request to the same URL. Since this URL exists in the local browser cache, it's cached contents and cached headers are returned. Since the previous request was not a Cross-Origin request, the cached headers do not include the Cross-Origin headers. This results in an XHR response with Status equal to 200 and a responseText equal to an empty string.


Note: See TracTickets for help on using tickets.