我正在尝试从数据库中获取事件并附加在完整日历上。为此,我使用了一个下拉列表,列出了几个月和一年。从下拉列表中选择月份并单击搜索按钮后,事件将添加到日历中。但是,当我尝试从下拉列表中更改月份,然后单击搜索按钮时,从数据库中正确提取了所选数据,但保留了旧事件,并且不刷新新的月份事件。下面是我的代码。
EventCalendar.aspx
<script>
$(document).ready(function () {
$("#searchBtn").click(function () {
var month = $('#ContentPlaceHolder2_DropDownMonth option:selected').val();
var user = $('#ContentPlaceHolder2_DDUser option:selected').val();
alert(month.split(" ")[0]);
var monthname = month.split(" ")[0];
var year = month.split(" ")[1];
var monthd = new Date(Date.parse(monthname + "1", year)).getMonth() + 1
var date = year + "-" + monthd + "-" + "1"
console.log(monthd)
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "NewUserScore.aspx/GetScoreDetails",
data: "{ 'userId':'" + user + "', 'month':'" + month + "'}",
success: function (result) {
events_array = …Run Code Online (Sandbox Code Playgroud)