<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function ondata(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(this.readyState==4 && this.status==200){
var javaobj = JSON.parse(xhttp.response);
document.getElementById('mass').innerHTML=javaobj.name;
}
};
xhttp.open("GET","student.json",true);
xhttp.send();
}
</script>
<input type="button"name="name" onclick="ondata()" value="Click"/>
<div id="mass"></div>
</body>
</html>
Я получил ошибку 6hp. html: 21 Доступ к XMLHttpRequest в 'file: /// C: /Users/Admin/Desktop/ind/ip-simple/student.json' from origin 'null' был заблокирован политикой CORS: запросы на разные источники поддерживаются только для схем протоколов: http, data, chrome, chrome -extension, https