繁体   English   中英

使用Ajax在Fullcalendar中保存事件

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM