Bug Tracker

Ticket #5156 (closed enhancement: duplicate)

Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#5156 closed enhancement (duplicate)

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:


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.

Change History

comment:1 Changed 5 years ago by addyosmani

comment:1 Changed 5 years ago by addyosmani

  • Keywords datatype added
  • Resolution set to duplicate
  • Status changed from new to closed

comment:2 Changed 5 years ago by addyosmani

comment:2 Changed 5 years ago by addyosmani

Duplicate of #6106.

Note: See TracTickets for help on using tickets.