AngularJS, downloading files in Internet Explorer after 60 seconds

I have an unusual problem that only occurs with IE.

I have a user interface for uploading files, in which the on-change event is connected to the Angular directive, which calls the web api service as such

 element.on('change', event => {
    scope.onChange();

    if (event.target.files.length > 0) {

        var fd = new FormData();
        fd.append('file', event.target.files[0]);

        $http.post('/api/upload', fd, {
                transformRequest: angular.identity,
                headers: { 'Content-Type': undefined },
            })
            .success(data => {
                scope.onSuccess({ data: data });
            })
            .error(data => {
                scope.onError({ data: data });
            });
    }
});

This is great for Firefox and Chrome. It also works great for IE if I don't return to the page and then wait 60 seconds (works fine if I wait less than 60 seconds).

If I wait 60 seconds, the onchange event is still triggered and a message will be attempted, however the API service will never be reached because the request is empty. This means that xmlhttprequest just hangs:

Pending requestEmpty request

Any ideas?

+2

Source: https://habr.com/ru/post/1548343/


All Articles