JSONP call showing “Uncaught SyntaxError: Unexpected token : ”

后端 未结 3 1652
故里飘歌
故里飘歌 2020-11-29 04:08

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=e         


        
3条回答
  •  醉梦人生
    2020-11-29 04:23

    You're trying to access a JSON, not JSONP.

    Notice the difference between your source:

    https://api.flightstats.com/flex/schedules/rest/v1/json/flight/AA/100/departing/2013/10/4?appId=19d57e69&appKey=e0ea60854c1205af43fd7b1203005d59&callback=?

    And actual JSONP (a wrapping function):

    http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=processJSON&tags=monkey&tagmode=any&format=json

    Search for JSON + CORS/Cross-domain policy and you will find hundreds of SO threads on this very topic.

提交回复
热议问题