Download a file with an ajax call

前端 未结 5 391
面向向阳花
面向向阳花 2021-01-13 11:25

I am using PHPExcel to read an excel template, populate the data, and ask the user to download the file.

generate_excel.php

$objPHPExcel = PHPExcel_I         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-01-13 11:38

    Found a way to do this, although I'm not sure if this is an ideal approach.

    I added a hidden iframe in the page. When the ajax call returns, it returns the url of the created data. I used javascript to redirect the iframe to that url which automatically triggers the download action.

提交回复
热议问题