The preventDefault() method needs to be called in the main context (before the onEventResize handler exits). You are calling it in the callback method which is called later and it has no effect.
The Pro version uses args.async to support asynchronous callbacks:
dp.onEventResize = function(args) {
args.async = true;
dp.message("Checking....");
$.ajax({
url: "asyncvalidation.txt",
method: "GET",
data: {
dateFrom: args.newStart.toString(),
dateTo: args.newEnd.toString(),
id: args.e.id()
}
}).done(function (response) {
var $response = $.parseJSON(response);
if ($response.error) {
dp.message($response.message);
args.preventDefault();
}
args.loaded();
});
};
In the Lite version you need to cancel the default action right away and perform it manually when the condition is met:
dp.onEventResize = function (args) {
args.preventDefault();
$.getJSON("ps.php?id=" + args.e.id(), function(data) {
var ok = checkCondition();
if (ok) {
e.start(args.newStart);
e.end(args.newEnd);
dp.events.update(args.e);
}
});
};
I assume the password reading code is just for demonstration purposes because it isn't secure at all.