Defect #30073

Ajax Request Returns 200 but an error event is fired instead of success

Added by Pavel Rosick√Ĺ about 1 month ago. Updated about 1 month ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:REST API
Target version:Candidate for next minor release
Resolution: Affected version:


here's an explanation of the issue

IMO any maybe other places should be changed to return (no-content) or a valid json {} if the dataType is json


        type: "DELETE",
        url: '/issues/5.json'
        dataType: 'json'
        success: function (data) {
        error: function (textStatus, errorThrown) {

if fails as an error, because the returned body is blank (not a valid json), but the request was successful

this behaviour is documented

dataType (default: Intelligent Guess (xml, json, script, or html))
Type: String
The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).

"json": Evaluates the response as JSON and returns a JavaScript object. Cross-domain "json" requests that have a callback placeholder, e.g. ?callback=?, are performed using JSONP unless the request includes jsonp: false in its request options. The JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. As of jQuery 1.9, an empty response is also rejected; the server should return a response of null or {} instead. (See for more information on proper JSON formatting.)

I propose to change

def render_api_ok
  render_api_head :ok

def render_api_ok
  render_api_head :no_content


#1 Updated by Go MAEDA about 1 month ago

  • Target version set to Candidate for next minor release

Also available in: Atom PDF