I'm trying to get two dates based on a selection from a previous dropdown.
Functionally, the process is working. However, I am getting a result of {object Object} instead of the dates.
PHP
$data=array();
while($row=mysql_fetch_array($result)) {
$data[]=array('start_date'=>date("m/d/Y",strtotime($row['start_date'])));
//log_msg(print_r($data, true));
}
echo (json_encode($data));
jQuery
.ajax({
type: 'POST',
url: 'admin_workshop_update_retrieve.php',
dataType: 'json',
data: 'value=' + choice,
success: function(data) {
$.each(data, function(k, v) {
$("#workshop_dates").append($('<option value ="' + v + '" >' + v + '</option><br>'));
});
}
});
It seems like I'm missing something easy to turn the JSON object into a string or text. Would greatly appreciate any help.
You should treat them as objects:
$("#workshop_dates").append($('<option value ="' + v.start_date + '" >' + v.start_date + '</option><br>'));