3 день пытаюсь разобраться с AJAX консоль выдаёт
Access to XMLHttpRequest at '
file:///C:/OpenServer/OSPanel/domains/testo.com/ip.php' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
ajaxGet @ script.js:9
document.querySelector.onclick @ script.js:3
файл index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ТЕСТО</title>
</head>
<body>
<input type="button" id="shop_ip" value="Show my IP">
<div id="myip"></div>
<script src="script.js"></script>
</body>
</html>
файл script.js
window.onload = function() {
document.querySelector('#shop_ip').onclick = function() {
ajaxGet();
}
}
function ajaxGet(){
var request = new XMLHttpRequest();
request.open('GET', 'ip.php');
request.send();
}
файл ip.php
<?php
echo $_SERVER('REMOTE_ADDR');
?>