0
我已經使用full calendar外部拖動事件的主題分配接口。使用ajax更新主題的詳細信息到MySQL數據庫,但阿賈克斯不工作。我沒有得到我的控制器中的值。檢查其他問題,但沒有找到解決辦法。可以幫助嗎?ajax不能使用完整的日曆
<link href='assets/fullcalendar/fullcalendar.css' rel='stylesheet' />
<link href='assets/fullcalendar/fullcalendar.print.css' rel='stylesheet' media='print' />
<script src='assets/fullcalendar/lib/moment.min.js'></script>
<script src='assets/js/jquery.js'></script>
<script src='assets/fullcalendar/lib/jquery-ui.custom.min.js'></script>
<script src='assets/fullcalendar/fullcalendar.min.js'> </script>
<script>
$(document).ready(function() {
/* initialize the external events
-----------------------------------------------------------------*/
$('#external-events .fc-event').each(function() {
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
// it doesn't need to have a start or end
var eventObject = {
title: $.trim($(this).text()) // use the element's text as the event title
};
// store the Event Object in the DOM element so we can get to it later
$(this).data('eventObject', eventObject);
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
/* initialize the calendar
-----------------------------------------------------------------*/
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
droppable: true,
drop: function(date,event) {
// retrieve the dropped element's stored Event Object
var originalEventObject = $(this).data('eventObject');
// we need to copy it, so that multiple events don't have a reference to the same object
var copiedEventObject = $.extend({}, originalEventObject);
// assign it the date that was reported
copiedEventObject.start = date;
// render the event on the calendar
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
// is the "remove after drop" checkbox checked?
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the "Draggable Events" list
$(this).remove();
}
$.ajax({
url: '/addSchedule',
dataType: 'json',
type: 'post',
data: {event: event},
success: function(response){
console.log('response');
}
});
}
});
});
</script>
'這不是working'不正確的問題陳述。什麼不起作用以及您遵循了哪些故障排除步驟? – charlietfl 2014-11-08 18:45:53
@charlietfl在完整日曆上發生拖放事件時使用ajax保存事件詳細信息,但ajax調用失敗。我沒有獲得控制器 – AVM 2014-11-08 18:54:50
@AVM中的值,您是否在控制檯中看到錯誤?此外,如果您將'error:function(jqXHR,textStatus,errorThrown){console.log(jqXHR)}'([請參閱文檔](http://api.jquery.com/jquery.ajax/))添加到您的$ ajax調用,你看到一條錯誤消息嗎? – 2014-11-09 16:44:48