Throw error if some validations fails when loading events

I have a function that verify if the logged user is authorized to see the events of another user (that can be selected from a combo). This combo displays users that authorized the logged user to view their events.
Till now, if the logged user try to view the events from another user and its not authorized gets an empty calendar since it doesn’t receive events to display (json response is “[]”).
It’s possible to display some alert indicating that it’s not authorized to see those events?

Thanks!

You can code on client side, which will check if data loaded or not, and show message after it

scheduler.attachEvent("onXLE", function(){ if (scheduler.getEvents(new Date(1000,1,1), new Date(9000,1,1).length == 0) webix.message("Empty data set loaded!"); });

it works, but the downside is that the alert will also be displayed when the user doesn’t have any events to display. I couldn’t find a way to make it work, since in “onXLE” event I can’t inspect the response.

What I want to achieve is:
Logged user is allowed to see events but there’s no events to display --> Do nothing
Logged user is NOT allowed to see events --> Display warning

Thanks for your help!

You can fallback to custom json processing

dhtmlxAjax.get("data.php", function(response){ var data = eval(response.xmlDoc.responseText); if (data.some_custom) alert("Error"); //show custom error message else scheduler.parse(data, "json"); //or load data in scheduler })

Thanks, I couldn’t make dhtmlxAjax.get to work correctly, but I finally got it working in this way:

scheduler.attachEvent("onEventLoading", function(event_object){ if (typeof(event_object.error) !== "undefined") { dhtmlx.message({ type: "error", text: event_object.error }); } else { this.addEvent(event_object); } });