Very new to jQuery, don't fully understand the differences between objects and arrays so I apologize if my terminolog is incorrect - please correct me!
I have a successful ajax return array from PHP:
$.ajax({
url: "......",
dataType: "json",
type: "GET",
data: {
start_date: start,
end_date: end
},
success: function (res) {
$.each(res, function( key, value ){
$('#FoundEvents').append('<option value="'+ key +'">'+ value +'</option>');
});
}
});
This gives me [object Object] in each option tag. To ask the obvious, I'm dealing with an object not an array? All the data is present, I just can't find the correct syntax to access it. How do I iterate the array data from this point?
If I understand my console readout correctly, there are 10 'objects' then inside each object are several 'keys:values'.
Thanks for your help!
Update
PHP Array is structured like so: $arr = array(1 => array(key=>value), 2 => array(key=>value) ...)
I'm trying to access values.
Update 2
Here's my new code:
$.each(res, function(index, item){
$.each(item, function(key, value){
if(key == "event_title")
{
Events.push({"event_title":value});
}
});
});
$.each(Events, function(index, value){
$('#FoundEvents').append('<option value="'+ index +'">'+ Events.value +'</option>');
});
But somehow I still have objects in my array? I don't understand why. I assume 'value' itself is the object... which I don't mind, but need to know how to pluck the data out.