Maor Cohen
Maor Cohen

Reputation: 956

API: Uncaught SyntaxError: Invalid or unexpected token

I'm trying to get the results for the term: 'german' from an api..

Unfortunately, I get error: 'Uncaught SyntaxError: Invalid or unexpected token'.

I see that there are html characters in middle dots in the overview response.. and there are lots of \" (it should escape the quates).

$.ajax({
    type: 'GET',
    url: url,
    async: false,
    jsonpCallback: 'testing',
    contentType: 'application/json',
    dataType: 'jsonp',
    success: function(json) {
        console.dir(json);
    },
    error: function(e) {
        console.log(e.message);
    }
});

This is my jsfiddle: http://jsfiddle.net/mrLkyx7j/

Thanks.

Upvotes: 0

Views: 4119

Answers (1)

Trushar Narodia
Trushar Narodia

Reputation: 366

try this code

$.ajax({
type: 'GET',
url: url,
jsonpCallback: 'testing',
dataType: 'json',
success: function(json) {
    console.log(json);
},
error: function(e) {
    console.log(e.message);
}
});

Upvotes: 2

Related Questions