Repb Adhy Musaad
Repb Adhy Musaad

Reputation: 11

Parsing json data with jquery eval

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

Answers (1)

user229044
user229044

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

Related Questions