繁体   English   中英

未捕获到的SyntaxError:JSON中的意外令牌u在JSON.parse的位置0

[英]Uncaught SyntaxError: Unexpected token u in JSON at position 0 at JSON.parse

我正在尝试学习JavaScript,并且不断收到错误消息“未捕获的SyntaxError:JSON中的意外令牌u,位于JSON.parse的位置0”。

var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', 'https://learnwebcode.github.io/json-example/animals-1.json');

ourRequest.onload = function(){
    var ourData  = JSON.parse(ourRequest.resoponseText);
    console.log(ourData[0]);
};
ourRequest.send();

您只是拼写了resoponseText应该是responseText 由于JavaScript最终调用JSON.parse("undefined")您将收到错误消息。

您有一个错字:您编写的是ourRequest.resoponseText而不是ourRequest.responseText

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM