My data is coming from PHP like this:
auth0: Object
"client_id: "1234"
tables: Array[2]
0: Object
clients_avail: "demo"
1: Object
clients_avail: "4532t78"
EDIT: Here's the actual JSON:
{"auth":{"id":"bob"},"tables":[{"clients_avail":"demo"},{"clients_avail":"4532t78"}]}
The above is retrieved like so:
$.ajax({
url: 'getit.php',
type: 'POST',
dataType: 'json',
data: {
id_token: my_token
},
success: function(data) {
$.each(full_data, function (data) {
$('#clients_avail').append("<option>" + data.tables.clients_avail + "</option>");
$('#my_id').text(data.auth.id);
}
});
This is coming back uncaught error:
Uncaught TypeError: Cannot read property 'clients_avail' of undefined
What am I missing here?
console.log(data)as the first line of the success handler and see what is logged in the browser consoletablesis an array of arrays, trydata.tables[0][0].clients_availto access first one. You should probably organize your PHP output better.tablesvalue.... why is itfull_data.tables, not overfull_data... This would be a lot easier if you posted the actual JSON string you are getting back instead of dump of some sort.