I want to read json from php server using javascript (not jquery) like
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
json = xmlhttp.responseText;
JSON.parse(json, function (key, val) {
alert(key + '-'+ val);
});
}
}
in php file i do
$data = array();
$data['id'] = '1';
$data['name'] = '2';
print json_encode($data);
But output is
id-1
name-2
-[object Object] // why??
How to fix that thanks