I have a little image resizing script which promptly offers the resulting resized image as a download. If this was a normal case where the result-content was being loaded within a div on the same page the js code below would have worked, as it does on my other part of the site. But here the scenario is that the output ( resized image ) is offered as a force download, which appears as a download prompt panel, hence the code below loads the loading.gif but fails to hide it. Hence the loading.gif remains visible.
I guess the codes i need either changed or fixed somehow, begins after line 6, below in the JS Code. Till then it is functional and works as expected. Please note that my resizing script is completely in php.
JS
<script type="text/javascript">
jQuery(document).ready(function() {
var $pageLoad = jQuery('.page-load');
$pageLoad.hide();
jQuery('#SubmitButton').on('click', function() {
$pageLoad.show(100);
});
//code till here works fine and triggers gif on submit but dunno after this
//what codes should go here to fadeout or hide the loading gif ?
//not even sure if this is right approach
});
</script>
HTML :
<form action="http://xxxxxxxxxxx/wp-content/themes/xxxxx/resize/resize.php" id="UploadForm" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" id="SubmitButton" name="SubmitButton" value="Upload" />
</form>
Just so you know, I use a wordpress cms and the resize script on a different .php page and the script uses session_start()
. I am just learning php and not familiar with JS at all. And Yes I am doing my own search, research and tweaks too. Nothing is working out till now. If you also need codes from resize.php for better reference please let me know.
Just for the sake of simplicity, here is a simple illustration of expected sequence.
The visitor clicks the submit button.
The data is submitted to resize.php as evident by forms action tag.
JS script above gets triggered and shows the hidden div class "page-load" which contains the loading gif ( so the visitor know something is happening ).
Now the resize process is done and the visitors gets a download and save panel.
ISSUE : The form page has reloaded but the loading gif is still visible. Hope that was clear.
Bottomline : How to hide the loading gif once download panel appears/image is resized.
First Update : Similar issue described here gathers votes but remains unsolved.
Second Update : I am still looking for an answer. I thought this would be a walk in a park. Gravely mistaken.