This question already has an answer here:
in php
<?php
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr); // {"a":1,"b":2,"c":3,"d":4,"e":5}
?>
in javascript,
$.getJSON('drivetracker2.php', function(data) {
console.log(data);
});
I am trying to access the php array which was sent via json to javascript.
but it says data is undefined.
anyone know why and how to fix this problem?
drivetracker2.php
in browser? – pktangyue Mar 19 at 9:13data
anywhere else? – Felix Kling Mar 19 at 9:15