[英]Saving event in Fullcalendar using Ajax
我正在使用全日歷,當我單擊日歷時,我想保存事件。
到目前為止,這就是我的工作,它正在處理表單中的提交元素,而不是日歷中的元素,例如,我無法獲取開始日期。
$('#calendar').fullCalendar({
...
select: function(start, end, allDay, event, resourceId) {
$('#add_appt').modal(); //openthemodal
$(document).ready(function(){
$('#EventAdd').submit(function(e) {
SubmitAppointment();
e.preventDefault();
});
});
function SubmitAppointment(){
hideshow('loading',1);
error(0);
$.ajax({
type: "POST",
url: "ajax.events.add.php",
// If I try this, I get all the elements of the form but no value for start I think it's my syntax that is wrong
data: $('#EventAdd').serialize(),start: start,
// If I try this, I get the start date but I don't know how to include the vales in EventAdd
data: 'start='+ start,
dataType: "json",
success: function(msg){
if(parseInt(msg.status)==1){
$('#add_appt').modal('hide');
//window.location=msg.txt;
}else if(parseInt(msg.status)==0){
error(1,msg.txt);
}
hideshow('loading',0);
}
});
}
有人可以幫我語法嗎? 因為我認為這才是真正的問題所在。
所以我找到了自己的問題的答案:
我用這個:
data: 'start='+ start+$('#EventAdd').serialize(),
代替這個
data: $('#EventAdd').serialize(),start: start,
我認為你必須通過data
的Ajax調用的參數,如果你想發送所有如下<form>
值和start
值:
data: $('#EventAdd').serialize() + "&start=" + start
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.