我需要将以下“事件”中的日期替换为从JSON调用返回的日期列表,这些日期存储在“ bookedDates”中。有人可以协助吗?
我也需要在每个日期都保留:{}。
<script type="text/javascript">
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
var currentDate = yyyy + '-' + mm;
var bookedDates = [];
$(document).ready(function () {
$.ajax({
type: "POST",
url: "/Ajax/getBooked",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
bookedDates = bookedDates.concat(response),
bookedDates.toString;
}
});
$(".responsive-calendar").responsiveCalendar({
time: currentDate,
events: {
"2015-06-30": {}
}
});
});
</script>
最佳答案
尝试这个,
events = {};
for (i = 0; i < bookedDates.length; i++) {
events[bookedDates[i]] = {};
}
演示小品:http://plnkr.co/edit/jz6cqrFN92DOrAekFfC8?p=preview,
转到控制台以查看事件对象