简体   繁体   中英

IE8 Json problem

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?

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

},],

to

}],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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