(CORB)阻断跨原点响应https://infinityfree.net/errors/404/具有MIME类型tex



当我在ajax请求中调用API时,我的页面中不断出现这个错误。我在另一个问题中检查了同样的东西,但并没有得到我页面的正确结果。请有人帮我找出你知道的答案。以下是我通过ajax请求调用Api的代码:

function getIP() { 
var bat=$('#battery').val();
var id="<?=$_SESSION["id"]?>";
var myip="<?=get_client_ip()?>";
$.ajax({
type: "post",
url: 'map.php',
data: {ip: myip,bat:bat,id:id},
success: function(data){
console.log(data);
}
});
}

并且被调用的页面具有闲置代码:

<?php
include('includes/connect.php');
$id = $_POST['id'];
$PublicIP = $_POST['ip'];
$battery = $_POST['bat'];
$json     = file_get_contents("https://ipinfo.io/$PublicIP/geo");
//echo($json);
$json     = json_decode($json, true);
$country  = $json['country'];
$region   = $json['region'];
$city     = $json['city'];
$postal   = $json['postal'];
$loc=$json['loc'];
?>

请有人帮我取得正确的结果。这段代码在我的本地中有效,但在我的服务器中无效。我也参考了https://stackoverflow.com/questions/50873764/cross-origin-read-blocking-corb,但没有得到合适的结果。请有人帮我。

这样尝试:

$json = file_get_contents("https://ipinfo.io/".$PublicIP."/geo");

最新更新