Hi i've got a problem evaluating json. My goal is to insert json member value to a function variable, take a look at this
function func_load_session(svar){
var id = '';
$.getJSON('data/session.php?load='+svar, function(json){
eval('id = json.'+svar);
});
return id;
}
this code i load session from php file that i've store beforehand. i store that session variable using dynamic var.
<?php
/*
* format ?var=[nama_var]&val=[nilai_nama_var]
*/
$var = $_GET['var'];
$val = $_GET['val'];
$load = $_GET['load'];
session_start();
if($var){
$_SESSION["$var"] = $val;
echo "Store SESSION[\"$var\"] = '".$_SESSION["$var"]."'";
}else if($load){
echo $_SESSION["$load"];
}
?>
using firebug, i get expected response but i also received error
uncaught exception: Syntax error, unrecognized expression: )
pointing at this
eval('id = json.'+svar);
i wonder how to solve this