Project

General

Profile

Actions

Defect #10761

closed

Rest API JSON response can not be parsed by jQuery

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

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate
Affected version:

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 supportClosedJean-Philippe Lang

Actions
Actions #1

Updated by Markus M over 12 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},.....}

Actions #2

Updated by Jean-Philippe Lang over 12 years ago

  • Status changed from New to Closed
  • Resolution set to Duplicate
Actions #3

Updated by Jean-Philippe Lang over 12 years ago

JSONP support added in r10088 for 2.1.0.

Actions

Also available in: Atom PDF