So I have a report php page where a user fills out a form, selects a bunch of options, the last one is a jquery select box which chooses what kind of file the report will be downloaded as. These reference java classes on a tomcat server that generate the file and return it when called by its url.
Soo.. What i’m trying to do is once the final option is selected and they press the go button, do all the prework and initiate the download. However I’m running into problems with ways to make this work right.
I can’t use the conventional headers for content and readfile, as i’ve already sent headers previously in the script/page. I created a download.php to hide the url and send headers off a clean script.
I need to somehow download or open in a new window: “
I’ve tried using every javascript and jquery method i can think of. If it tries to open a new window or new tab, Firefox and IE both “block pop up” warning comes up – and that’s not really acceptable for a business app, imo.
Tried using an <a href> link and using javascript to .click() it, however that still triggers the firefox and IE stock pop-up blockers.
I’ve tried using <object> but never got it to actually download/hit that page.
Tried using hidden <iframe> tags and just specifing the src= as the url i want to download, and it works, however whenever the iframe is shown on the page (after submission), all other javascript on the pages stop working. IE my JS menu, calendars, collapsable panels. It’s like it loads this iframe which starts a download/pop-up, and it stops loading all the javascript on the page or something.. I don’t really know. I haven’t found a good way to refresh the page either afterwards (which might resolve it), because refreshing the page without accepting or finishing the download cancels it.
IDK, i hope that makes sense. I’m looking for ideas of other ways I can initiate a download of a url, without breaking the JS on the page or without getting a pop-up block warning in IE or FF.
Thanks everyone!