IE8 Json problem

走远了吗. 提交于 2019-12-11 06:26:53

问题


I'm facing very strange issue, I'm getting JSON object from django powered site and excuting it using eval(). It works on all the other browsers except all versions of IE. in IE, I am getting "variable_name" is null or not an object. I've tried everything I could but so far no luck.

here is my json object

var results = {"result":[
{
    "artist":"somevalue",
    "song":"someothervalue",
    "file":"filepathvalue",
    "views":"0",
    "songid":"1007",
    "artistimage":"default.jpg"
},

{
    "artist":"artistname",
    "song":"songname",
    "file":"anotherfilepath value",
    "views":"0",
    "songid":"1008",
    "artistimage":"default.jpg"
},
],
"prev_page": "0",
"next_page": "2"
}; 

Note:

alert(results.result[0].song)

work just fine, but

$('#somediv').html('<span>'+results.result[0].song+'</span>');

does not work in IE. any idea?


回答1:


Your result array has an extra comma at the end. remove it and it should be fine.

},],

to

}],


来源:https://stackoverflow.com/questions/1925057/ie8-json-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!