gpt4 book ai didi

php - 无法在fullcalendar控件中显示json数据

转载 作者:行者123 更新时间:2023-12-01 05:22:19 25 4
gpt4 key购买 nike

{
"date":"2017-02-13",
"start":"2017-02-13 12:13:53",
"end":"2017-02-13 12:14:05",
"attendance":"P"
}

这是我在成功函数上从 mysql 获得的 json 数据,但数据未在日历上呈现。谁能告诉我吗?

这是我的事件:

    events: [],

events: function (start, end, timezone, callback)
{

var data = {

action : "attendance_records",
userid : userid
};

$.ajax({
type: "POST",
url: "model_attendance_table.php",
dataType: 'json',
data: data,
success: function (data, textStatus, jqXHR)
{

var events = [];

$(data).each(function(){

events.push({

title: 'title',
start:$(this).attr('start'),
end:$(this).attr('end')

});


});
callback(events);

}

});
}

而且我还收到回调未定义的错误。

最佳答案

尝试这样做。它对我有用。

events: function (start, end, timezone, callback)
{
$.ajax({
url: 'url that return json',
type: 'GET',
dataType: 'json',
data: {
userid: localStorage.getItem("userid"),
start: start.unix(),
end: end.unix()
},
success: function (doc) {
alert(doc);
alert(JSON.stringify(doc));
var events = [];
$(doc).each(function () {

events.push({
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end')
});
});
callback(events);

},
error: function (jqXHR, status, err) {
alert("fail");
alert('there was an error while fetching events!' + err);
},
complete: function (jqXHR, status) {
// alert("Local completion callback." + status);
}
});

}

关于php - 无法在fullcalendar控件中显示json数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42199971/

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