jQuery AJAX Preloader Problem
Hi I am using this script for submitting my form data to php page its working well...
<script type="text/javascript">
$(document).ready(function() { 开发者_如何学Python
$('#preloader').hide();
$('#preloader')
.ajaxStart(function(){
$(this).show();
}).ajaxStop(function(){
$(this).hide();
});
$('#form form').submit(function(){
$('#content').empty();
$.get('data.php', $(this).serialize(), function(data){
$('#content').html(data);
});
return false;
});
});
</script>
But the problem is if jquery fails to load or if javascript is turned off in browser the hide function continues to display what i need is ... the loading div only shows up if jquery loads successfully or is there any other trick for doing that Thankyou...
Also hide element with CSS, example:
<div id="preloader" style="display:none;"></div>
So if JS is disabled then CSS will work, and if JS is enabled both will work which is not a problem.
精彩评论