jquery - How to display and remove a loading .gif when downloading a file? -
I have a button that is clicked on to download a file by submitting a form using POST is needed. [ Edit to clarify: The file being downloaded is generated through the PHP script based on the values in the dynamically hidden form (which is the click based on the jQuery I I change through). The file in question is an excel file. I would not like to use GET if possible, because I do not want people to link directly to the file.] I was unable to use the The solution was to use Example code: However, since the file can take several seconds to generate, so I wanted the user to display the loading animation GIF. Now the problem presents that I can display the animation, but after the form is submitted I can not remove the animation. If this method can not be used, can there be a better solution to suggest? You should either serve URLs in GIF or it should be encoded as base 64 $ .post I'm the form because it does not work as I would like, when the submission is okay, it does not trigger the download dialog box in the browser. As I understand, the content of the file is now present in Javascript, and there is no way (which I know) that allows you to send it to JavaScript to download it in JavaScript. Therefore, other solutions (for example) will not work in this particular case.
$ ("# someform"). Submit (); When a hidden form was clicked on the button the page does not reload, and the dialog pops up on the screen.
$ ("#button") .click (function () {$ (this) .removeClass ("button"); $ (this) .addClass ("Loading"); $ ("#form") Submit ();});
Comments
Post a Comment