我如何知道服务器是否已打开JSONP?

问题描述:

我如何知道服务器是否已打开JSONP?它不是我的服务器,但是我尝试从渲染的html访问一些信息.

How do I know if a server has JSONP turned on? It is not my server, but I try to access some information from the rendered html.

谢谢.

对于大多数 服务器,您可以在浏览器中向其拥有的任何JSON页面/服务发出请求,而只需添加一个回调函数在网址中输入,例如:

For most servers, you can make a request in your browser to whatever JSON page/service they have and just add a callback function in the URL, for example if it's this:

http://example.com/getJson?var=something

添加callback查询参数,如下所示:

Add the callback query parameter, like this:

http://example.com/getJson?var=something&callback=myFunction

响应而不是此响应(如果它不支持JSONP,它将显示为 ):

The response instead of this (it will look like this if it doesn't support JSONP):

{ "thing": "value" .... }

应该看起来像这样(再次, if 它支持JSONP):

Should look like this (again, if it supports JSONP):

myFunction({ "thing": "value" .... });