jquery loop on Json data using $.each

前端 未结 4 1984
后悔当初
后悔当初 2020-11-22 14:56

I have the following JSON returned in a variable called data.

THIS IS THE JSON THAT GETS RETURNED...

[ 
{\"Id\": 10004, \"PageName\"         


        
4条回答
  •  迷失自我
    2020-11-22 15:42

    Have you converted your data from string to JavaScript object?

    You can do it with data = eval('(' + string_data + ')'); or, which is safer, data = JSON.parse(string_data); but later will only works in FF 3.5 or if you include json2.js

    jQuery since 1.4.1 also have function for that, $.parseJSON().

    But actually, $.getJSON() should give you already parsed json object, so you should just check everything thoroughly, there is little mistake buried somewhere, like you might have forgotten to quote something in json, or one of the brackets is missing.

提交回复
热议问题