I am using a JSON string to pass a variable in JavaScript from PHP :
while( $row = mysql_fetch_array($result) )
{
$tmp = array('id'=>$row['id'], 'alert_type_id'=>$row['alert_type_id'], 'deviation'=>$row['deviation'], 'threshold_low'=>$row['threshold_low'], 'threshold_high'=>$row['threshold_high']) ;
$settings[] = $tmp ;
}
echo '{"data":'.json_encode($settings).'}' ;
in Javascript, i am using the following snippet :
console.log( result ) ;
var json = eval('('+ result +')') ;
and what appears in the Console is the following error :
1{"data":[{"id":"1","alert_type_id":"1","deviation":null,"threshold_low":"20","threshold_high":"80"}]}
SyntaxError: Expected token ')'
Could you please help me overcome this issue please ? Many Thanks.