I am trying to pass an array with json in php:
$array = array ($a, $b, $c);
echo json_encode($array);
and to use it in jquery like this:
$(function () {
$.ajax({
url: 'api.php',
data: "",
dataType: 'json',
success: function (data) {
var id = data[3];
var vname = data[1];
$('#description').html("<b>id: </b>" + id + "<b> name: </b>" + vname);
}
});
});
But this prints as "id: [object Object] name: [object Object]" instead of the values I want, I get that..
What am I doing wrong? Thank you for any help..