I have a div that contains a "processing" animation that is triggered when a form is submitted.
<form action='index.php?page=2' method='post' onsubmit="javascript:processingBox();">
Works great for MOST pages. The issue I have, is that some of my forms trigger a download with the following code:
//BEGIN DOWNLOAD HEADER SECTION//
header("Pragma: public", true);
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-Disposition: attachment; filename='.$filename);
header("Content-Transfer-Encoding: binary");
header('Connection: Keep-Alive');
//WRITE OUT HEADER//
echo $output;
//WRITE OUT RECORDS//
while ($row = mysqli_fetch_array($sql)) {
$output = "";
for ($i = 0; $i < $columns_total; $i++) {
$output .= $_POST['enclosed'] . $row["$i"] . $_POST['enclosed'] . $_POST['delimiter'];
}
echo "\r\n";
echo substr($output,0,strlen($output)-1);
}
exit;
The obvious problem here, is that this script does not refresh the page (as its designed not to) but it wont clear the processing splash that is made visible on submit.
Any best practices for this scenario?
Edit:
<script type="text/javascript">
function processingBox() {
div = document.getElementById('processingBox');
div.style.visibility = "visible";
}
</script>
<div class='processingBox' id='processingBox'>
<h1 style='margin-top:0px;margin-bottom:30px;'>Processing</h1>
<div class="circle"></div>
<div class="circle1"></div>
</div>