I am using jQuery Datepicker and i am trying to highlights dates coming from mysql through ajax. This is my code.
var appendDate = '';
var days_custom = '';
$( "#datepicker").datepicker({
dateFormat: 'yy-mm-dd',
beforeShowDay: function(date) {
$.ajax({
type: "GET",
url: URL,
success: function(data)
{
var data1 = jQuery.parseJSON(data);
days_custom = '[';
for(i=0;i<data1.length;i++)
{
days_custom = days_custom + '"'+data1[i].mddate+'",';
}
days_custom.slice(0,-1)+']';
appendDate = days_custom;
}
});
var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
for (i = 0; i < appendDate.length; i++) {
if($.inArray(y + '-' + (m+1) + '-' + d,appendDate) != -1) {
return [true, 'free-day', 'no to-do items due'];
}
}
return [true];
}
});
$('.free-day').find('a').css("color","yellow");
$('.free-day').find('a').css("background","rgba(0, 0, 0, 0.74)");
});
Now from ajax success i am returning dates in this format which is JSON
[{"status":"3","mddate":"2016-06-07"},{"status":"3","mddate":"2016-06-14"},{"status":"3","mddate":"2016-06-09"},{"status":"3","mddate":"2016-06-10"}]
And the appendDate
format should be like this
["2016-8-21","2016-8-24","2016-8-27","2016-8-28"];
I am not able to highlight dates on datepicker coming from mysql. how to resolve this