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

Also available in: Atom PDF