我有这个代码创建一个事件对象数组,然后传递给日历,但由于某种原因,日历不会呈现事件。
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'title',
center: '',
right: 'prev,next'
},
editable: true,
eventLimit: true,
events: function(start, end, timezone, callback) {
$.ajax({
success: function(doc) {
var events = [];
$.getJSON('../php/logg.php', function(data) {
$.each(data, function(key, val){
var temp = moment($(this).attr('dato'))
if(temp.isBefore(start)){ return true; }
else if(temp.isAfter(end)){ return true; }
else{x
events.push({
id: $(this).attr('id'),
title: $(this).attr('artist'),
start: $(this).attr('dato'),
allDay: false
});
}
}
);
});
var ektearray = $.makeArray(events);
callback(events);
}
});
}
});
});
当我将事件输出到控制台时,我得到一个对象数组,这些对象似乎按预期工作。对象采用以下形式:
allDay:false
id:"66"
start:"2016-11-04"
title:"Galantis"
__proto__:Object
好像我要么搞乱了回调,要么我的事件遗漏了什么,但我似乎无法弄清楚是什么
答案 0 :(得分:0)
如果我理解正确,您希望在function(doc)
来电成功后执行ajax
。如果是这样,你的语法似乎没有被正确编写。
$.ajax({
method: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.success(function() {
alert( "success" );
});