how to wait for server response before changing an event

Hi,

I’d like to controll whether the event should be updated after a confirmation from the server. I have something like the following

scheduler.attachEvent(“onBeforeEventChanged”, function(ev, e, flag, ev_old){
function ajaxCallToServer(callback)
{
# do ajax call
if (success)
return callback(true);
else
return callback(false);
}

 var response = ajaxCallToServer(function(isSuccessful){
      return isSuccessful;
 });

 return response;

}}))

What’s wrong with this code? This onBeforeEventChanged event does not wait for the callback, simply returns response as undefined.

Thanks,

Nick

The event of scheduler do work in sync. mode, they will not wait for asyn ajax operations. You can try to change the code and use sync. ajax call in the ajaxCallToServer function.