Hi,
Why do I not see the spinner image when I run this code? However when I debug through it using firebug I do see the text/spinner image at the beginning:
<div id="spinner">
<img src="/images/ajax-loader.gif"/>
Text
</div>
<div id="events">
</div>
<script type="text/javascript" charset="utf-8">
function load_events() {
$("#events").load("robots.txt");
}
$(document).ready(function(){
$("#spinner").show()
$("#events").hide()
setTimeout("load_events()",2000);
$("#events").show()
$("#spinner").hide()
});
</script>
thanks
PS. In particular I need it so the spinner will keep showing until the AJAX response from the "load" actually all comes back (not until the load event itself starts, as the API I'm calling then still takes a couple of seconds before it comes back with the content)
PSS. Latest code I'm using after feedback. Still suffers from issue noted in the PS above.
<div id="spinner"> <img src="/images/ajax-loader.gif"/> </div>
<div id="events"> </div>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#spinner").show();
$("#events").hide();
setTimeout(function(){
$("#events").load("weekends/concerts_display");
$("#events").show();
$("#spinner").hide();
},10);
});
</script>