views:

78

answers:

2

Hi,

I'm generating a file on the server which takes some time. For this, I have a hidden iframe which I then set the .src attribute to an aspx file i.e iframe.src = "/downloadFile.aspx"

While this is taking place, I'd like to have a call to a web service return the progress. To do this, I thought I could use window.setInterval or window.setTimeout but Javascript seems to be blocked as soon as I set the iframe src attribute.

Does anyone know how to get around this or perhaps try a different approach?

I have also tried handlers, but the request never gets to the server so I'm assuming is a browser/javascript issue.

//Function that gets the file

function GetFile() {
        setTimeout(GetProgress, 1000);

        var iframe = document.createElement("iframe");
        document.body.appendChild(iframe);

        iframe.src = "downloadFile.aspx";
}

/*DOES NOT WORK - Function that gets progress posts data but never recieves it until the iframe has finished and presents the file download dialog to the user. */

function GetProgress() {

        $.post('progress.file', function(data) {

            console.log(data);
            setTimeout(GetProgress, 1000);
        });
    }
A: 

Not sure exactly what you doing, but try putting your iframe.src=... code in window.setTimeout as well.

Strelok
this has not fixed my issue :(
Sir Psycho