1
votes

I have a situation where I am utilizing fullCalendar, but I need it to go to a new page with some POST info and not utilize AJAX.

I simply am trying to make it so when the event is clicked it is sent to a new page with some POST info. Below is the code with the last line being an attempt to send info through a URL, but if there is any way of sending the info via a POST with AJAX instead to the page that could work too.

$(document).ready(function() {
   var calendar = $('#calendar').fullCalendar({
    editable:false,
    header:{
     left:'prev,next today',
     center:'title',
     right:'month,agendaWeek,agendaDay'
    },
    events: 'Calander_inc/load.php',
    selectable:true,
    selectHelper:true,
    select: function(start, end, allDay)
    {
     var title = prompt("Enter Event Title");
     if(title)
     {
      var start = $.fullCalendar.formatDate(start, "Y-MM-DD HH:mm:ss");
      var end = $.fullCalendar.formatDate(end, "Y-MM-DD HH:mm:ss");
      $.ajax({
       url:"insert.php",
       type:"POST",
       data:{title:title, start:start, end:end},
       success:function()
       {
        calendar.fullCalendar('refetchEvents');
        alert("Added Successfully");
       }
      })
     }
    },
    editable:true,
    eventResize:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
        
     $.ajax({
      url:"update.php",
      type:"POST",
      data:{title:title, start:start, end:end, id:id, url:url},
      success:function(){
       calendar.fullCalendar('refetchEvents');
       alert('Event Update');
      }
     })
    },

    eventDrop:function(event)
    {
     var start = $.fullCalendar.formatDate(event.start, "Y-MM-DD HH:mm:ss");
     var end = $.fullCalendar.formatDate(event.end, "Y-MM-DD HH:mm:ss");
     var title = event.title;
     var id = event.id;
     $.ajax({
      url:"update.php",
      type:"POST",
      data:{title:title, start:start, end:end, id:id},
      success:function()
      {
       calendar.fullCalendar('refetchEvents');
       alert("Event Updated");
      }
     });
    },
    eventClick:function(info)
    {
            var id2 = event.id;
            window.open("Calander_inc/see-info.php?idgig=" + encodeURI(id2),"_self");
    },
    eventRender: function(event, element) {
      $(element).tooltip({title: event.title});             
    }
  });
 });
</script>
Just put the title, start, end, id, url into say input boxes in a form and submit by POSTKen Lee
Why do you care about sending it via POST? You're only sending an ID to the see-info.php page. It's fine to do that as a GET. And it makes semantic sense because you're requesting to view a specific record, not submitting new data to be saved.ADyson
P.S. You could do this via AJAX - e.g. send an AJAX request to a URL containing the event ID, and the URL could return data about that event. You could then have JS code which displays the event info you want, for example in a HTML modal popup. It's really up to you.ADyson