Ajax works asynchronously: When this
Code:
$('#calendar').fullCalendar('addEventSource', JSON.parse(freshevents));
is executed, the variable freshevents is not yet set. You have to move this insctruction to the success callback:
Code:
$('#employees').change(function(){
//alert($('#employees').val());
var userid=$('#employees').val();
$.ajax({
url: 'process.php',
type: 'POST', // Send post data
data: 'type=fetch&userid='+userid,
async: false,
success: function(s){
$('#calendar').fullCalendar('addEventSource', JSON.parse(s));
}
});
});
Edit: Sorry, I didn't notice that you set async to false. Anyway I would recommend doing without this and place the instruction inside the success callback.