Defect #10761

Rest API JSON response can not be parsed by jQuery

Added by Toshiya TSURU over 5 years ago. Updated over 5 years ago.

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

0%

Category:REST API
Target version:-
Resolution:Duplicate Affected version:1.3.3

Description

When I tried to get data via Rest API with json formatting,
I got an error message saying "Uncaught SyntaxError: Unexpected token :" with Chrome 18, jQuery 1.7.2.

Here is the javascript code :

$(function() {
    $.ajax({
        type : 'GET',
        url : "http://www.redmine.org/trackers.json",
        success : function(data) {
            alert(data);
        },
        dataType : 'jsonp'
    });
});

But the confusing thing is that the response of the API seems to be valid...

http://www.redmine.org/trackers.json

Then, I tired to call Wikipedia API in the same javascript code,
This was successfully done.

$(function() {
    $.ajax({
        type : 'GET',
        url : "en.wikipedia.org/w/api.php?action=query&titles=redmine&prop=info&redirects=&format=json",
        success : function(data) {
            alert(data);
        },
        dataType : 'jsonp'
    });
});

Related issues

Related to Redmine - Feature #11469: JSONP support Closed

History

#1 Updated by Markus M over 5 years ago

First of all, does Redmine-REST-API support JSONP? (I found your issue with google because I was researching, if Redmine supports JSONP. I need JSONP)

It seems like JSONP is not supported. You can try it with this query for your issue: http://www.redmine.org/issues/10761.json?callback=dd

The response should be:

dd({{"issue":{"author":{"name":"Toshiya TSURU","id":2509},.....})

But it's still:

{{"issue":{"author":{"name":"Toshiya TSURU","id":2509},.....}

#2 Updated by Jean-Philippe Lang over 5 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate

#3 Updated by Jean-Philippe Lang over 5 years ago

JSONP support added in r10088 for 2.1.0.

Also available in: Atom PDF