Calculate answer time for Progress Bar

1

I have a function in AJAX that returns a file. What I want to do is implement a Progress Bar with a percentage so that the user knows how the download of their file is going. Use C # MVC4 , my method in the controller is a FileResult , and here I show my code in jQuery :

$('#DownBtn').on('click', function () {

    $.ajax({
        url: "/Servicio/DescargaData",
        type: "GET",
        dataType: 'binary',
        beforeSend: function () {
            cargar();
        },
        success: function (result) {
            var url = URL.createObjectURL(result);
            var $a = $('<a />', {
                'href': url,
                'download': 'DataServicio.xlsx',
                'text': "click"
            }).hide().appendTo("body")[0].click();
            setTimeout(function () {
                URL.revokeObjectURL(url);
            }, 10000);
            noCargar();
        }
    });
});

I want to add that to do that, I use a file called jquery.binaryTransport that I found it by goingogle. I do not know if it is the right way to do it, as you can see, I put a setTime because that is the time that I calculated from the database in showing the data and the processing. Well, I think it's wrong, I need to know the exact processing percentages from the controller.

    
asked by cristian gonzalez 13.01.2017 в 05:07
source

0 answers