Basically, i'm using an JSON response from a local PHP file to append data inside a div, currently it's only returning one variable, in which the code i'm using is shown here :
$.ajax({
url: "functions/ajax.php",
data: "func=auto",
type: "GET",
dataType: "json",
success: function(data){
$.each(data.search, function (i, v) {
$div = $('.bs-docs-example');
$div.append('+ v +');
});
},
error: function (jqXHR, textStatus, errorThrown){
console.log('Error ' + jqXHR);
}
});
The code which is returning the JSON is currently
while($row = mysql_fetch_assoc($res)) {
$search[] = $row['number'];
}
echo json_encode($search);
What i want to do is something like this
while($row = mysql_fetch_assoc($res)) {
$search[] = $row['number'];
$search[] = $row['name'];
}
echo json_encode($search);
But if i was to do the following, how would i access both number and name since in the success on the jQuery it's parsing using $.each(data.search, function (i, v) { which means the original $search[] = $row['number'] is now stored inside v
would i do something like v['name'] v['number'] or is that completely wrong ?