【发布时间】:2010-11-20 23:17:51
【问题描述】:
【问题讨论】:
-
你谷歌了吗?什么不清楚?关于 JSONP 的文章很多。
【问题讨论】:
【讨论】:
JSONP 代表带有填充的 JSON,它为客户端提供了一种方法来指定一些应添加到 JSON 响应开头的代码。这允许在浏览器中直接执行 JSONP 响应。 JSONP 响应的一个示例可能是:
processResults({value1: "Hello", value2: "World"})
我认为 JSONP 的主要用处是使用 <script> 标签跨域发出请求。我认为主要的缺点是,由于直接执行 JSONP,您必须相信远程站点不会发回任何恶意内容。但是我不得不承认我没有在实践中使用过这种技术。
编辑:Remote JSON - JSONP 提供了更多信息,说明您为什么要使用该技术的发明者。
【讨论】:
引用this blog:
The purpose of JSONP is to overcome the boundaries of the infamous same-domain-policy which restricts XHR requests to the same domain meaning that you cannot make Ajax requests to other domains. There’s no need to worry about that with JSONP because it doesn’t even require Ajax to work; all it’s doing is using script tags and callbacks…
【讨论】: