Uploader "onBeforeAjax" event

Signatures for the "onBeforeAjax" event do not match.

ajax
callEvent("onBeforeAjax", [mode, url, params, x, headers, null, defer])

Uploader
callEvent("onBeforeAjax", ["POST", url, details, xhr, headers, formData])

https://docs.webix.com/desktop__server_customload.html#modifyingbackgroundajaxrequests

Tagged:

Comments

  • edited September 2019

    Hey @lBeJIuk, the passed in parameters do match from what I can see. If we go by the article that you yourself linked, we can see that the parameters seem to match:

    webix.attachEvent("onBeforeAjax", 
        function(mode, url, data, request, headers, files, promise){
          // in the case of uploader promise is not passed in = undefined
          // in the case of any other AJAX request files (formData) = null
        }
    );
    

    This is different simply because in the case of uploader we are actually sending the data (files argument = formData), whereas in the other cases we are not.

  • @Dzmitry Yeah, that's right. But in the case of Uploader, "promise" is not sent.

  • edited September 2019

    You are correct, this is the intended behaviour, as the file uploading process isn't the same as sending a standart webix.ajax request and doesn't use the promise API, which is why it is not being sent.

    Is there any particular reason why this is an issue in your case? As far as I'm aware, you can make a use of the uploader events and cover most of the use cases.

    Or, perhaps, you want this to be reflected somewhere in the documentation, and you were pointing out the inconsistency?

  • @Dzmitry
    I use "onBeforeAjax" to make a global response interceptor.
    Something like that:

      UiAdapter.attachEvent('onBeforeAjax', function(method, url, params, xhr, headers, data, promise) {
        if (promise) { // < Workaround
          promise
            .then(function(data) {
            // Error/notification check, etc.
    ...
    

    And when trying to use Uploader, it was found that the event was called with other parameters.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!