views:

122

answers:

1

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?

+3  A: 

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

},],

to

}],
ICodeWith.Net
+1 for Good spot!
Matt Ellen
Thanks, sometimes easy things are hard to figure out.
Mohamed
This, for the record, is a horribly vexing IE bug. When you add a comma at the end of a list, IE parses that as there being an extra 'undefined' at the end. This also means the length is off by one.
Daniel Bruce
@daniel, I agree with you, it is a nasty bug considering that all the other browsers behave well.
Mohamed