[英]Saving event in Fullcalendar using Ajax
I am using fullcalendar and I would like to save events when I click on the calendar. 我正在使用全日历,当我单击日历时,我想保存事件。
This is what I have so far, which is working with the submitted elements from the form but not from the calendar, for example I cannot get the start date. 到目前为止,这就是我的工作,它正在处理表单中的提交元素,而不是日历中的元素,例如,我无法获取开始日期。
$('#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);
}
});
}
Can someone help me with the syntax ? 有人可以帮我语法吗? Because I think that's where the problem really is. 因为我认为这才是真正的问题所在。
So I found the answer to my own question : 所以我找到了自己的问题的答案:
I use this : 我用这个:
data: 'start='+ start+$('#EventAdd').serialize(),
instead of this 代替这个
data: $('#EventAdd').serialize(),start: start,
我认为你必须通过data
的Ajax调用的参数,如果你想发送所有如下<form>
值和start
值:
data: $('#EventAdd').serialize() + "&start=" + start
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.