Send a PHP array to jQuery
I have array like this:
Code:
$offices[$data['Id_Office']] = array($data['Name'], $data['Address'], $data['Telephone']);
echo json_encode($offices);
Now in the jQuery side, I make an AJAX request like this and trying to extract value from returned PHP array:
PHP Code:
.
.
$.ajax({
type: "POST",
url: "ajax.php",
//dataType: 'jsonp',
data: "townid="+ town,
success: function(arrayPHP){
$.each(arrayPHP, function (i, msg) {
$("#name").html(msg);
$("#address").html(msg);
$("#telephone").html(msg);
});
}
});
Firebug show this:
Code:
{"2":["agence01","address01","5465460"]}
But in this part no text looks to be appear:
Code:
<label for="Name">Name: </label><span id="name"></span><br />
<label for="Address">Address: </label><span id="address"></span><br />
<label for="Telephone">Telephone: </label><span id="telephone"></span>