[英]json file not found when using AJAX
Here is my code 这是我的代码
var xml = new XMLHttpRequest(); xml.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');
I tried to load a json file but it says 我试图加载一个json文件,但它说
net::ERR_FILE_NOT_FOUND
净:: ERR_FILE_NOT_FOUND
I checked the source, the json file is there. 我检查了源,那里有json文件。 So I don't know what's wrong with my code here.
所以我不知道我的代码在哪里出问题。 Help me please
请帮帮我
Another option... 另外一个选项...
const url = 'https://learnwebcode.github.io/json-example/animals-1.json'
fetch(url)
.then(
response => response.text() // .json(), etc.
// same as function(response) {return response.text();}
).then(
html => console.log(html)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.