<分区>
我在使用所有其他链接从 api 接收数据时遇到问题它没问题但是那个太难了..所以这是代码
$.ajax({
url: 'proxy.php?url=https://na.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo/NA1/26667724?api_key=xxxx',
dataType:"json",
success: function() {
alert("Success");
},
error: function() {
console.log("Error")
}
});
这是我正在使用的 php 代码。
<?php
header("Content-Type: text/javascript; charset=utf-8");
if (!isset($_GET['url'])) {
die();
}
$url = urldecode($_GET['url']);
$url = 'https://' . str_replace('https://', '', $url);
echo file_get_contents($url);
?>
在控制台上显示日志--->XMLHttpRequest cannot load file:///D:/Install/xampp/htdocs/allInOne/proxy.php?url= https://na.api.pvp.n …pectatorGameInfo/NA1/26667724?api_key=xxx。跨源请求仅支持协议(protocol)方案:http、data、chrome、chrome-extension、https、chrome-extension-resource.send@jquery-1.11.3.js:9664jQuery.extend.ajax@jquery-1.11.3。 js:9215jQuery.(匿名函数)@jquery-1.11.3.js:9361jQuery.extend.getJSON@jquery-1.11.3.js:9344renderInfo@render.js:89onclick@index.html:15 render.js:85 错误