Skip to main content

Bug Tracker

Side navigation

#5859 closed bug (fixed)

Opened January 19, 2010 12:14AM UTC

Closed January 23, 2010 10:08PM UTC

Last modified March 09, 2012 04:34PM UTC

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:
Description

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)

Attachments (0)
Change History (4)

Changed January 23, 2010 10:08PM UTC by john comment:1

component: unfilledajax
resolution: → fixed
status: newclosed

Changed January 26, 2010 04:39PM UTC by coolaj86 comment:2

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.

Changed April 04, 2010 01:31PM UTC by scosenz comment:3

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

Changed April 05, 2010 04:15PM UTC by scosenz comment:4

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.

-Steve