我如何知道服务器是否已打开JSONP? [英] How do I know if a server has JSONP turned on?

查看:81
本文介绍了我如何知道服务器是否已打开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" .... });

这篇关于我如何知道服务器是否已打开JSONP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆