I am running a FullCalendar, and I would like to retrieve some data via a jQuery post when a day is clicked. This is the code:
dayClick: function(date, jsEvent, view) {
truckid=jQuery(this).parents(".calendar").attr("data-truck-id");
alert(truckid);
jQuery.post( "test.php", { TruckId: truckid, dateUsed: date })
.done(function( data ) {
alert( "Data Loaded: " + data );
});
alert('everything OK');
},
When I include the jQuery post, the script fires the "alert(truckid)" part, and then stops with the following error: TypeError: a is undefined (points to moment.min.js a js file of FullCalendar).
If I remove the jQuery post, the code runs correctly, alerting out the last alert too.
What could be the problem? Thanks for the help in advance!
Found the solution. The problem is with the date variable, which is a moment object, thus can't be sent this way. Here is a solution to this problem, thanks to PatBau: