Javascript 如何使jquery加载微调器自动进行?

Javascript 如何使jquery加载微调器自动进行?,javascript,jquery,spinner,loading,gif,Javascript,Jquery,Spinner,Loading,Gif,我使用了来自Github的JQuery等待微调器演示,并根据自己的喜好对其进行了修改。我希望微调器在页面出现时自动启动,以便有时间加载页面上较大的图像,但此时必须单击“开始等待”以等待微调器出现 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Untitled Document</title> <lin

我使用了来自Github的JQuery等待微调器演示,并根据自己的喜好对其进行了修改。我希望微调器在页面出现时自动启动,以便有时间加载页面上较大的图像,但此时必须单击“开始等待”以等待微调器出现

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
<link href="waiting.css" rel="stylesheet" type="text/css" />

<style type="text/css">
body {
margin: 50px;
}
.content {
margin-bottom: 50px;
max-width: 500px;
}
button.waiting-done {
display: none;
}
</style>


<!--script src="../libs/jquery/jquery.js"></script-->
<script src="jquery-2.0.2.min.js"></script>
<script src=" jquery.waiting.min.js"></script>

<script type="text/javascript">
$(function () {
var content = $('.content').first().html();
$('button').on('click', function () {
$(this).toggle().siblings('button').toggle();

if ($(this).hasClass('waiting-done')) {
$(this).siblings('.content').waiting('done')
.html(content.substring(0,Math.random() * content.length) + '...');
}
});
});
</script>
</head>

<body>

<div id="demo-fixed">
><button type="button" class="waiting">► start waiting</button>
><button type="button" class="waiting-done">■ waiting done</button>

<div class="content">
</div>

</div>
<script type="text/javascript">
$('#demo-fixed button.waiting').on('click', function () {
var that = this;
$(this).siblings('.content').waiting({ fixed: true });
setTimeout(function() {
$(that).siblings('button').click();
}, 3000);
});
</script>
</body>
</html>
这是我的第一篇文章,所以我希望我已经提供了足够的信息让人们理解。我可以复制JQuery,但内容太多,我不确定相关部分


提前感谢您的帮助。

jQuery内置了一个很好的工具,您可以阅读

$(document).ajaxStart(function() {
//start spinner 
});

$(document).ajaxStop(function() {
//stop spinner 
});


$(document).ajaxError(function(event, jqXhr, ajaxSettings, thrownError) {
// handle the error
});