gpt4 book ai didi

javascript - 输出javascript数组的内容

转载 作者:行者123 更新时间:2023-11-30 16:48:45 25 4
gpt4 key购买 nike

我需要用存储在“bookedDates”中的 JSON 调用返回的日期列表替换下面“事件”中的日期。有人可以帮忙吗?

我还需要在每个日期保留 :{}。

<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 ,去控制台看事件对象

关于javascript - 输出javascript数组的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30849299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com