0

In the jsp, I use javascript, jquery and json to call a function for download, once the the download is finished, it will return the the current page.

However the problem is although the download is complete, I can able to download and view the file. In the screen, it still show the message indicate it is downloading.

I read this post, the accepted solution mentioned to disable the cache with ajaxSetup. I read my code, I have already include it in the code, however the Internet Explorer still not return to proper page when the download finished. Is there any method I can use to solve the problem. Thank you.

function startDownload() {
    $.blockUI({ message: '<h1>Downloading, please wait...</h1>' });  
    var i = setInterval(function() { 
        $.ajaxSetup({ cache: false }); 
        $.getJSON("ThePage/downloadProgress?jsoncallback=?",function(download_token) {
        if (download_token.fileDownloadToken == "finished" ) { 
            $.unblockUI(); 
            clearInterval(i);           
        } 
        });  
    }, 1000);  
}

Update I mentioned it occurs on IE because our company is mainly using IE for the web browser. So I intend to make to code works on the IE first. Sorry for the inconvenience that I have made.

Learner
  • 727
  • 4
  • 13
  • Are you saying the problem occurs *only* in IE, or have you not tried other browsers? – nnnnnn Nov 15 '17 at 02:19
  • checking every second? that could cause issues if the latency is high – Jaromanda X Nov 15 '17 at 02:29
  • @nnnnnn, thanks for your comment. I tried to test on Google Chrome and the result is the same. It does not refresh nor return to the current page when the download is completed. In the question, I mentioned it occurs on IE because our company is mainly using IE for the web browser. So I intend to make to code works on the IE first. Sorry for the inconvenience that I have made. – Learner Nov 15 '17 at 02:40
  • @JaromandaX, thanks for your comment. About `check every second` this issue, I have discussed with my colleagues, although they told me the reason to check every second is to ensure the progress is processing, I don't think it is necessary to check every second. Grateful if you could you suggest what is the appropriate time for checking to prevent the high latency, please? – Learner Nov 15 '17 at 02:47
  • I updated the content of the post mentioned I will try to solve on IE browser. Thanks for reading. – Learner Nov 15 '17 at 02:50
  • there is no appropriate time ... I would do it a completely different way ... wait some time (1 second or less) after previous response has completed before making another request - like [this](https://jsfiddle.net/x4vt4x1d/) – Jaromanda X Nov 15 '17 at 02:56
  • @JaromandaX, thanks for your comment. Would you mind put your comment into answer please and if possible with some code, I believe it will be useful for future reference. – Learner Nov 15 '17 at 03:16
  • it is not an answer, because it won't fix any issue you actually have (there is no change in logic at all, really) – Jaromanda X Nov 15 '17 at 03:16

0 Answers0