When I make a selction on the calendar and add an event, it sends the info to my PHP script and the event is placed in the database as expected. Great!
The problem is when I select another date and add the event (without refresh), it adds the event twice in the MYSQL database. Not Great!
This perpetually adds up with the increasing clicks until a refresh is made. Also the “extra” events added have no time placed in the DB except for “0000-00-00 00:00:00”, so in turn it appear correct upon output. Am I just missing something simple? What am I doing wrong?
<script>
$(document).ready(function(){
select: function(start, end, allDay){
$("popup").show();
$(".title").focus();
var start = Date.parse(start) / 1000;
var end = Date.parse(end) / 1000;
var allDay = allDay:
$("submitForm").click(function(){
var title = $(".title").val();
var description = $("description").val();
var team_id = <?php echo $id ?>;
if(title != "" || title != " "){
$.post("script.php", {...}, function(){
$(".title").val("");
$(".description").val("");
start = "";
end = "";
title = "";
description = "";
team_id = "";
allDay = "";
calendar.fullCalendar('unselect');
calendar.fullCalendar('refetchEvents');
});
}else{
alert("You must enter a title");
}
$(".popup").hide();
});
}
});
</script>
Obviously this is not the entire JS/Jquery but this is what matters. What am I missing? Thanks in advance. Your help is appreciated!
I actually had to add a random session id to fix the problem and then clear the id after the post was completed.