0

I use the following ajax to open a url that make and download xls and pdf reports. This open a iframe in jquery dialog. When the dialog open the user will must wait to download the file. When the file downloaded I want to close the dialog.

I tried the following but is not work any idea?

$.ajax({
    type: 'POST',
    url: '../menu/solonreport.jsp',
    data: {
        Wreportid: reportid,
        Wreporttype: reporttype
    },
    async: false,
    dataType: 'json',
    success: function(json) {
        var ifr = $('<iframe/>', {
            id: 'iframereport',
            src: json.url,
            style: 'display:none',
            load: function() {
                $("#dialog-report").dialog("close");
            }
          }
        });

        $("#dialog-report").append(ifr).dialog();    
});

following the html:

<div id="dialog-report" title="Eκτύπωση" style="display: none;">
    <span class="ui-icon ui-icon-info" style="float:left; margin:0 7px 50px 0;"></span>
    Please wait...
    <iframe id="iframereport" src=""  width="0" height="0"></iframe>
</div>
Giorgos
  • 637
  • 3
  • 13
  • 25
  • Not sure, but my answer here might help http://stackoverflow.com/questions/29532788/how-to-display-a-loading-animation-while-file-is-generated-for-download – Salketer Nov 19 '15 at 14:57

1 Answers1

0

There is a syntax error in the code you copied. You are missing a closing bracket for your success callback

        $("#dialog-report").append(ifr).dialog();  
     } //This one is missing
 })

I hope that your problem is only that

Dranes
  • 156
  • 10