javascript - (CORB) blocked cross-origin response https://infinityfree.net/errors/404/ with MIME type text/html
Get the solution ↓↓↓I keep on getting this error in my page when I call the API in ajax request. I checked same thing in another question but did not get the proper result for my page.Please someone help me with the answers you know.Here is my code that calls the Api through ajax request:
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);
}
});
}
and the page called has the fallowing code:
<?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'];
?>
Please someone help me to get the proper result.This code works in my local but not in my server.I refered this alsohttps://stackoverflow.com/questions/50873764/cross-origin-read-blocking-corb
but did not get proper result for mine.Please someone help me.
Answer
Solution:
Try like this:
$json = file_get_contents("https://ipinfo.io/".$PublicIP."/geo");
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot add or update a child row: a foreign key constraint fails
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.