Tutorial :IE8 Json problem



Question:

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?


Solution:1

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

},],  

to

}],  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »