Ajax bug (or not bug)?

Hello, it took me some times to figuring out that my ajax callback is not called when the response code is > 400.

I use the latest version of webix GPL. And the problem is on webix.ajax.$callback :



for (var i=0; i < call.length; i++) //there can be multiple callbacks

if (call[i]){

var method = (call[i].success||call[i]);

if (is_error)

method = call[i].error;

if (method && method.call)

method.call(owner,text,data,x);

}


And i change the line :
method = call[i].error;
to:
method = (call[i].error||call[i]);

Back to my question, is it bug? Or I am doing wrong on working with webix.ajax?

Hello,

The thing is that normal Ajax callback (or an array of callbacks) is a successful one. To call the server error callback, you can:

(1) explicitly provide success and error callbacks:

webix.ajax("some.php",{
    error:onErrorCallback,
    success:onSuccessCallback
});

(2) use Promise Api to catch the error:

var promise = webix.ajax("some.php")
promise.then(function success(realdata){}, function error(err){});

For detailed info on Ajax requests in Webix, please consult the related article.

Hello,

thanks for the answer and I will change my code to follow webix ajax design.