我试图解析从电影数据库返回的JSON数据。我收到一条错误消息,告诉我我收到以下错误消息:
Uncaught SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at XMLHttpRequest.movieReq.onreadystatechange (discover.js:34)
at loadIMDBDetails (discover.js:38)
at MainFunc (discover.js:68)
at discover.js:5
I am accessing individual movie information using the following XMLHttpRequest:
movieReq.open('GET',' https: //api.themoviedb.org/3/movie/299537?api_key = ',false);
我还有其他XMLHttpRequests可以返回JSON数据。这些请求正在使用API的发现功能。
这是产生问题的功能
function loadIMDBDetails(mO, i) {
movieReq = new XMLHttpRequest();
movieReq.onreadystatechange = function () {
var parsedObj = JSON.parse(movieReq.responseText);
mO.imdbId = parsedObj['imdb_id'];
};
movieReq.open('GET', 'https://api.themoviedb.org/3/movie/299537?api_key=34f8307d9addabf7924eab7f22cabb23', false);
movieReq.send();
}
When using console.log to return the responseText, this is the result:
慕哥6287543
相关分类