我在修复此错误时遇到问题。可能有人可以解释这里发生了什么:我正在从服务器返回 JSON:
d3.json(fullpath, function (json)
{
graphData = json;
if (graphData.nodes.length == 0)
{
$.jnotify("Sorry there is no data for graph. Please include social media type in search.");
}
drawGraph();
});
这是json的一部分:
"nodes": [{
"id": 1,
"userID": 1,
"profile_image_url": "images/twitterimage_1.jpg",
"description": "user1 desc",
"name": "user 1",
"location": "Berlin",
"statuses_count": 5,
"followers_count": 1
}
,
{
"id": 2,
"userID": 2,
"profile_image_url": "images/twitterimage_2.png",
"description": "user2343434 desc",
"name": "user 2",
"location": "Berlin",
"statuses_count": 6,
"followers_count": 2
}
然后在这一行:'if(graphData.nodes.length == 0)'我确实有这个错误:'错误:无法获取属性'nodes'的值:对象为空或未定义'
这仅在 IE 中,在 Chrome 或 Firefox 中不是问题。
请帮忙!
谢谢!