【问题标题】:Can't getJSON from 3rd party website无法从 3rd 方网站获取 JSON
【发布时间】:2018-03-26 11:45:24
【问题描述】:

我想得到

https://www.g2a.com/lucene/search/quick?jsoncallback=jQuery1110048787688104918936_1507980736882&phrase=punch&isWholesale=false&cc=PL&skip=&start=0&rows=5&_=1507980736886

这是 g2a 在搜索框中搜索的响应。我试过这个:

$.ajax({
url: url,
type: "GET",
dataType: "jsonp",
success: function (data) {
    console.log(data);
}});

但我得到一个错误:

jquery-3.2.1.min.js:4 Refused to load the script 'https://www.g2a.com/lucene/search/quick?jsoncallback=jQuery1110048787688104918936_1507980736882&phrase=s&isWholesale=false&cc=PL&skip=&start=0&rows=5&&callback=jQuery32104612888467884788_1507987847332&_=1507987847333' because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".

你可以看到它是一个 chrome 扩展,所以它不能有一些 PHP 脚本,可以在网上找到。

【问题讨论】:

    标签: jquery json get jsonp


    【解决方案1】:

    您必须在 menifest.json 中为服务器添加一个条目,如下所示-

    "content_security_policy": "script-src 'self' https://www.g2a.com; object-src 'self'"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-14
      • 1970-01-01
      • 2015-06-01
      • 1970-01-01
      • 2021-08-14
      • 1970-01-01
      相关资源
      最近更新 更多