jquery ui datepicker のプラグインとして JavaScript ファイルを操作しようとしています。基本的に、休日の予約を表すデータベース テーブルがあり、日付ピッカー カレンダーから日付を選択できます。すでに予約されている日の選択を無効にしようとしています。ここに私のjavascriptファイルがあります:
$(document).ready(function () {
$("#checkin").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: 'DD, d MM, yy',
altField: '#date_in',
altFormat: 'yy-mm-dd',
beforeShowDay: markInvalidDates,
onChangeMonthYear: fetchFreeDays,
firstDay: 1 // rows starts on Monday
});
$("#checkout").datepicker({
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: 'DD, d MM, yy',
altField: '#date_out',
altFormat: 'yy-mm-dd',
beforeShowDay: highlightDays,
onChangeMonthYear: fetchFreeDays,
firstDay: 1 // rows starts on Monday
});
});
var invalidDays = [];
function getReservations() {
$.ajax({
type: "POST",
url: "MullinsBayServices.asmx/GetVerifiedReservations",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "false",
success: function(response) {
var unvailableDates = response.d;
$.each(unvailableDates, function(index, date) {
invalidDays.push(date);
});
},
failure: function(msg) {
$('#output').text(msg);
}
});
function markInvalidDates(date) {
getReservations();
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if ($.inArray(dmy, invalidDays) == -1) {
return [true, ""];
} else {
return [false,"","Unavailable"];
}
}
私はまだjavascript/jqueryに慣れていないので、ここでどこが間違っているのかわかりません。WebサービスがJSONで適切にシリアル化された日付を返すと仮定すると、これは私が達成しようとしていることに対して正しいですか?