JSONP request returning error: “Uncaught SyntaxError: Unexpected token :”

后端 未结 2 926
谎友^
谎友^ 2020-12-05 04:45

So I\'m trying to make a request to the Stack Exchange API with the following jQuery code:

$.ajax({                                                                   


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-05 05:31

    Try this URL: http://api.stackoverflow.com/1.1/stats?jsonp=callme

    "callme" is the name of your callback function - in your GLOBAL NAMESPACE (window object).

    By the way, if you are running Firefox and have the JSONView add-on installed you can test the above URL (and yours for comparison) directly.

    Result from calling the URL:

    callme({
      "statistics": [
    ...
      ]
    })
    

提交回复
热议问题