Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF file download through XHR Request

Is it totally impossible to download a pdf file through an XHR request? I know there are many other discussions already on this topic but sadly, I am still not satisfied with them. I am using AngularJs and making a request by using its $Http method. It is not returning any file download popup. But if I hit with the same URL in a new Browser Window then I am getting a popup. I have already tried a work-arround and its working fine i.e. document.location.href = url; but If I do this then I am unable to show the waiting image till the time the download popup is ready and appeared. So the work arround is not enough for me. I would like to do it with a genuine way through a request to the server through which I can handle the alternative flows of the outcome as well.

like image 319
Ch Faizan Mustansar Avatar asked Nov 28 '13 07:11

Ch Faizan Mustansar


1 Answers

Have a look at this JQuery plugin jquery-file-download-plugin and here is the demo page of this plugin demo . I think its inserting iframe dynamically to DOM and produces look and feel just like AJAX request. It might be helpful for you.

like image 133
muneebShabbir Avatar answered Oct 29 '22 22:10

muneebShabbir