I'm trying to show a loading animation while the user waits for a call to the server. To do this I tried showing a div with JQuery but it only works in Firefox (not in IE or Chrome).
Right now, the BigSlowFuncCall only has a c# System.Threading.Thread.Sleep(10000);
JAVASCRIPT
function showloading() {
$('#content').hide();
$('#siteLoader').show();
}
function hideloading() {
$('#content').show();
$('#siteLoader').hide();
}
function CheckFields() {
showloading();
var jsHandler = new JsonHandler();
jsHandler.BigSlowFuncCall();
hideloading();
}
HTML
<div id="wrapper">
<div id="siteLoader" style="display:none;" >
<div id='siteDetailLoader'>
<img src='img/loading.gif' border='0' alt='cargando'>
Por favor, espera<br /> <br />
</div>
</div>
<div id="content">
<form>
<p>
/* Stuff */
</p>
<p class="submit"><input type="button" id="btn" onclick="CheckFields()" class="button-link" value="Descargar"/></p>
</form>
</div><!-- #content-->
</div><!-- #wrapper -->
This works as expected on Firefox (hides the content, shows the loading animation and after 10s hides the loading animation) but in IE it only shows if I quit the hideloading()
function and only after it exits the CheckFields function.
How can this so simple code work fine on Firefox but not on IE?
Edit:
I saw that if I put an alert()
after showloading()
it works perfectly. So, I've searched and found this: Forcing a DOM refresh in Internet explorer after javascript dom manipulation. I tried this https://stackoverflow.com/a/4271996/1824011 but it didn't work either.