-1

I am trying to detect when the PDF file is returned from the .php file that is generating it. Obviously when the download link appears then it is returned. However, I would like to implement a loading screen while the pdf file is being create.

Below I have the function that runs the .php file that generates the pdf.

Thank you!

function popupClick2 (){
    var popupObj2 = {};
    var c = '0';
    var p = '0';
    var i = '0';

    document.location.href = 'popupAjax2.php?yearPop='+$('#year').val()
                                                      +'&rangeD='+$('#rangeD').val()
                                                      +'&checkboxI='+i
                                                      +'&checkboxP='+p
                                                      +'&checkboxC='+c
                                                      +'&type='+$('#pdfcsv').val();
    closePopup2();
}
vector
  • 199
  • 1
  • 4
  • 17
  • I posted bellow what you should do, not the pure written code, as there are a lot of answered questions of how you can accomplish what you need. Please ask there for further information, or update this question with your updated code, if it's not working. – besciualex Jul 20 '15 at 15:24

1 Answers1

0

Let's assume you are on page preview_book.php. Here you have a link Download PDF. On this preview_book.php you should implement an javascript code that makes an ajax request to your download_pdf.php file.

Here is a link how you could do it: download file using an ajax request

On that ajax request, you also attach beforeSend: function(){} and onComplete:function(){}.

On beforeSend function you should make an loading gif visible, and onComplete you should hide it.

Full documentation on Jquery AJAX request is here.

Community
  • 1
  • 1
besciualex
  • 1,872
  • 1
  • 15
  • 20