Global ajax error handler

Hi

My app is build using Webix Jet.
I have a
webix.attachEvent(“onBeforeAjax”,function(request){ … });
that adds extra headers required by the backend API, ie. an Oauth2 bearer-token.

Now, I would like to add a global error-handler to all Ajax-calls. If the Bearer-token is expired, I need to handle that. And this can happen for almost all requests my app makes to the API.

How is that done? Is there perhaps something like an ‘onAjaxError’ event?

You can use onAjaxError event, will work for most data loading operations.
http://docs.webix.com/desktop__loadingerror.html

Or a bit more complicated solution, that will work for any webix.ajax request

	function start_event(mode,url,params,xhr,headers,data,promise){
		if (promise)
			promise.then( null, error_handler );
	}

	webix.attachEvent("onBeforeAjax", start_event);

where error_handler is ajax error callback

Thanks, very helpfull.

I could not find the ‘onAjaxError’ event mentioned in the API-docs, and had not found the page about management of loading errors.

To me, it would make sense to mention the ‘onAjaxError’ and ‘onBeforeAjax’ events in the API-docs, under ajax: http://docs.webix.com/api__refs__ajax.html