I have ajax code as follows which returns data correctly in format i required to be used ina jQuery timepicker function.
Ajax:
<script type="text/javascript">
$('#consultdate').change(function() {
consultdate = $('#consultdate').val();
userid= '<?php echo $user_id;?>';
cat = '<?php echo $category;?>';
//alert(consultdate);
var booked_dates;
$.ajax({
type: "POST",
url: 'qry/date-time_qry.php',
dataType : "text",
data: {consultdate : consultdate, userid : userid, cat : cat },
success: function(data)
{
alert(data);
booked_dates = data;
},
error : function() {
alert("error while loading data");
}
});
});
</script>
The data is returned in format:
['12:30 PM','12:45 PM'],['07:30 AM','07:45 AM']
Which is to be used in a jQuery timepicker function (disableTimeRanges):
<script>
$(document).ready(function(){
$('input#consulttime').timepicker({
'timeFormat': 'h:i A',
'disableTextInput': true,
'minTime': '<?php echo $consultation_start; ?>',
'maxTime': '<?php echo $consultation_end; ?>',
'disableTimeRanges': [
['8.30 AM', '8.45 AM'],
['12:15 PM', '12:30 PM']
//document.write= booked_dates;
],
'step': 15
});
});
</script>
The data is to be used for 'disableTimeRanges': which is currently hardcoded for testing.
I tried using document.write= booked_dates; without success.
How can i insert the data values (booked_dates) in the disableTimeRanges without using id?
I am a newbie just learning the skills and hope you forgive me for any oversight on my part.
I tried