This has been asked many times. But none of the solutions work for me in IE and Chrome.
Basically I want to show the boot image while an ajax call is being made.
Here is what I am trying to do.
function ws(){ showL(); var res=$.ajax({url:'webservice.asp?service=LoadingTestSRV',async:false,cache:false}).responseText; $('#dv').html(res); hideL(); $('#complete').html('Done'); } function showL() { $('#loading').show(); } function hideL() { $('#loading').hide(); }
Below is the HTML
<table cellspacing="1" cellpadding="1" border="1"> <tr><td> <input type="button" value="ckick" id="btn" onClick="ws();"> <input type="button" value="clear" onClick="$('#dv,#complete').html('');"> </td><td> <div id="dv"></div> </td></tr><tr> <td>Here<div id="loading" style="display:none" >Loading.................</div></td> <td>final<div id="complete"></div></td></tr> </table>
After the above js I tried
- ajaxStart and ajaxStop
- $. Ajaxsetup
- $. Ajax ({...}). Did (hideL)
All the js codes I tried work in Firefox, but none of them work in IE and Chrome. In Firefox, the code works as expected. The loading div is shown, ajax is called, the loading div is hidden. This is exactly what I expect. In IE and Chrome, the loading of the div is not displayed. Maybe it will be shown and hidden very quickly after or before calling ajax.
Please let me know what can be done to make the code work in IE and Chrome.
There must be some workaround since I saw other sites showing loading div. Or maybe I'm doing something stupid.
As soon as the code works in all browsers. I want to create a generic function (e.g. jQuery plugin) to show a loading div when ajax is called.
source share