Skip to main content

Bug Tracker

Side navigation

#14533 closed bug (duplicate)

Opened November 12, 2013 10:52PM UTC

Closed November 12, 2013 11:01PM UTC

Content-Type of application/json with Content-Length: 0 causes jQuery to fail the request

Reported by: aaron.l.france@gmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 2.1.0-beta1
Keywords: Cc:
Blocked by: Blocking:
Description

Content-Type of application/json with Content-Length: 0 causes jQuery to fail the request.

The reasoning is that the empty string is not valid JSON. Whilst, technically correct (the best kind of correct!), jQuery shouldn't really fail in such a non-intuitive way.

The Content-Type should be used as a 'best try first' parsing for the response. If the response says "application/banana" by all means, try to parse it as a banana, but if it's a peach, then surely we should be able to continue?

After all, a remote server shouldn't be able to crash our application (barring application programmer error).

Attachments (0)
Change History (1)

Changed November 12, 2013 11:01PM UTC by dmethvin comment:1

resolution: → duplicate
status: newclosed

Duplicate of #13756.Certainly a remote server could "crash" your application by returning invalid json, such as {bad or an empty string. If you don't trust the server, declare an explicit dataType: text and parse it yourself, then handle (or ignore) the error.