Reputation: 11
My source code:
function getdata()
{$(document).ready(function(){
$('#data').load('getdata.php');
jsonStatus=eval("("+reqIntiAjax.responseText+")");
});
}
setInterval("getdata()",300);
my data: [{"data1":1,"data2":4}]
how to decode json data with jquery? im using getdata=eval("("+reqIntiAjax.responseText+")"); its not work
Upvotes: 0
Views: 68
Reputation: 239270
Use $.getJSON
to have jQuery automatically parse the JSON for you, or use JSON.parse
to decode the JSON yourself. There is absolutely no reason to use eval
for this.
Upvotes: 2