In my application I want to show a datepicker (jquery) where only some dates are enabled. I get those dates from MySql DB. How can I send these paramemeters to datepicker through ajax?
<input type="text" name="t_Date" id="t_Date">
<script>
$("#t_Date").datepicker({
datesEnabled : ajax_getDates.php // Here what I need help
});
</script>
I don't know whether the getDates
methode exists or not.
Do an ajax request and create the date picker on success callback:
<input type="text" name="t_Date" id="t_Date">
<script type="text/javascript">
$(document).ready(function() {
$.post('ajax_getDates.php', {}, function(data){
$("#t_Date").datepicker({ datesEnabled : data.datesEnabled });
}, 'json');
});
</script>
The ajax_getDates.php
file should look like:
<?php
$datesEnabled = array('date1', 'date2', 'date3');
echo json_encode('datesEnabled' => $datesEnabled);