Jquery.ajax API request in JSON format causes “Uncaught SyntaxError: Unexpected token :” in Chrome

微笑、不失礼 提交于 2019-12-06 08:57:45
Eric Bridger

My guess is that the service at http://api.playground.brewerydb.com/beer/ is returning json but NOT jsonp. Search the jsonp tag for "Unexpected token" and you'll find many explanations such as this one. The json must be wrapped in a javascript function, i.e. the callback but it is up to the cross domain Web Service to support jsonp. This is enforced by the browser and jQuery cannot overcome it.

The API doesn't support JSONP by design

no we don't [support JSONP], as you would have to expose your API key. Best thing to do is setup an intermediate proxy on your side.

see twitter.

Note the folks over at the Open Beer Database do support JSONP.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!