Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSONP call showing "Uncaught SyntaxError: Unexpected token : "

Tags:

jquery

jsonp

Here is my code

$.ajax({         url: 'https://api.flightstats.com/flex/schedules/rest/v1/json/flight/AA/100/departing/2013/10/4?appId=19d57e69&appKey=e0ea60854c1205af43fd7b1203005d59&callback=?',         dataType: 'JSONP',         jsonpCallback: 'jsonCallback',         type : 'GET',         async: false,         crossDomain: true,         success: function(data) {             console.log(data);         }     }); 

What am I doing wrong? should I add or change anything in here? Any help would be appreciated. Thanks

like image 999
Katakam Nikhil Avatar asked Oct 03 '13 17:10

Katakam Nikhil


1 Answers

Working fiddle:

http://jsfiddle.net/repjt/

$.ajax({     url: 'https://api.flightstats.com/flex/schedules/rest/v1/jsonp/flight/AA/100/departing/2013/10/4?appId=19d57e69&appKey=e0ea60854c1205af43fd7b1203005d59',     dataType: 'JSONP',     jsonpCallback: 'callback',     type: 'GET',     success: function (data) {         console.log(data);     } }); 

I had to manually set the callback to callback, since that's all the remote service seems to support. I also changed the url to specify that I wanted jsonp.

like image 85
Jason P Avatar answered Sep 23 '22 09:09

Jason P