I'm using a JQUERY Time Picker for my PHP reservation system
$('#Ttime').timepicker({
'timeFormat': 'h:i A'
});
it works well but when I add the 'disableTimeRanges',
$('#Ttime').timepicker({
'timeFormat': 'h:i A'
'disableTimeRanges': unavailableTime
});
I start having problems with disabling specific time ranges. Those time ranges are from my database, which I put in arrays
$sql="SELECT treatment_time FROM reserve_detail WHERE therapist_ID = '".$q."'";
$result = mysql_query($sql) or die(mysql_error());
$rows = array();
$a = array();
while($data = mysql_fetch_array($result)) {
$rows[] = $data['treatment_time'];
$time= strtotime($data['treatment_time']);
$interval = date("h:i A", strtotime('+30 minutes', $time));
while (list($key, $original) = each($rows)) {
$a[] = ([$original,$interval]);
// $a = "['".$original."','".$interval."'],";
// $b = implode("-",$a);
}
}
print json_encode($a);
and I call it using AJAX.
$("#Ttime").focus(function(){
$.ajax({
url: '../admin/thname.php',
data: "q="+id,
dataType: 'json',
async : false,
success: function(data){
unavailableTime = data;
}
});
});
It disables/works when I tried hardcoding it like this:
var unavailableTime = [["12:00 AM","12:30 AM"],["1:00 AM","01:30 AM"]];
but when I use AJAX, it doesn't disables. I tried using alert on it,
success: function(data){
unavailableTime = data;
alert(data)
}
it shows the time from my database. Meaning my variable has my data on it.
I've researched about this on the net, I've tried their solutions but nothing seems to work.
Can anyone please help me with this problem ?