Say I have the file ‘burp_json.php’ with this content:
[php]
$a[‘persons’] = array(
array(‘first_name’ => ‘Daniel’, ‘last_name’ => ‘Oraca’),
array(‘first_name’ => ‘Daniel2’, ‘last_name’ => ‘Oraca2’),
);
echo json_encode($a);die();
[/php]
And how do I use the $a array in Javascript?
With this piece of JS code:
[javascript]
http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
$.getJSON( ‘burp_json.php’, function(data) {
$.each( data.persons, function(i, person) {
console.log(person);
});
});
[/javascript]