KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Export via Ajax #164

Open jackywest opened this topic on on Dec 6, 2017 - 3 comments

jackywest commented on Dec 6, 2017

Hi i'm trying to export and download via Ajax. But the method toBrowser doesn't seem to work well.

My user click on the button -> an ajax post is made -> koolreport export to browser -> ? but it doesn't download the file. I checked the response and it seems to send the good request-header and name but the browser don't trigger the download.

KoolReport commented on Dec 6, 2017

That's correct. You will not download file through ajax. You should make a post/get to server then server return file using toBrowser(). Please view our example.

If you really want to use ajax, you may need to make ajax call to server then use saveAs() to save the PDF file. After that, return the url of pdf file as text. At client-side, you set the window.location.href to that url then the file can be downloaded. Or you can generate an <a> link for user to click to download.

jackywest commented on Dec 7, 2017

Ok i think i'll do it like that. But i need to save it on tmp folder. is the script use the tmp folder and how i get that path file ? Is it obligatory to use the extra settings temp folder ?

KoolReport commented on Dec 7, 2017

Hi,

The saveAs() function will help you to save to any folder you want. So you can create your own folder and save the pdf there.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None