Jquery getJSON Uncaught SyntaxError: Unexpected token : error

后端 未结 4 1411
面向向阳花
面向向阳花 2021-01-03 16:27

I am trying to connect to the RubyGems API, but when I try to get the JSON I get an stange error.

Uncaught SyntaxError: Unexpected token :

4条回答
  •  旧时难觅i
    2021-01-03 17:03

    The browser is interpreting the curly brackets as a block. The API needs to return a function call with the JSON data as the argument (using the supplied callback name). It doesn't appear that this API supports JSONP & the callback parameter so you'll need to contact them to ask for this support.

    It should return something like:

    jsonp1279196981233({ ... })
    

    rather than simply:

    { ... }
    

    because the client will be evaluating it as a script. In JavaScript a set of stand alone curly braces will denote a block.

提交回复
热议问题