Skip to main content

Bug Tracker

Side navigation

#5156 closed enhancement (duplicate)

Opened September 01, 2009 05:22PM UTC

Closed October 26, 2010 05:59PM UTC

Last modified March 10, 2012 06:38AM UTC

Empty JSON response

Reported by: Rantanen Owned by:
Priority: major Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: json datatype Cc:
Blocked by: Blocking:
Description

jQuery gives a 'parsererror' when using the jQuery.ajax method with 'json' as datatype and the response is empty.

Ajax endpoints that "may or may not" return data are not that far fetched. An example would be a web service to a transactional data model where undoing a transaction returns the previous resource representation which might be null if there is no previous representation. While empty string is not valid JSON, I believe this should result in a succesful ajax call with null or undefined data (neither of which has valid JSON representation). It is cleaner to distinguish null from a valid object in the success handler than to delegate the "parsererror" resulting from an empty string from the error handler to the success handler so I don't believe allowing empty JSON should cause that much troubles.

The empty responses can be worked around by using a dataFilter that converts "" to "null", but it would be nice if this was built in.

#4326 might be related to this.

Attachments (0)
Change History (2)

Changed October 26, 2010 05:59PM UTC by addyosmani comment:1

keywords: jsonjson datatype
resolution: → duplicate
status: newclosed

Changed October 26, 2010 05:59PM UTC by addyosmani comment:2

Duplicate of #6106.