後,我想在頁面加載 我這個嘗試後隱藏微調:隱藏Spinner加載
$(document).ready(function() {
$('.loader')
.hide() // Hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
});
});
我有這個div:
<style>
.loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url("{{ asset('img/loading.gif') }}") 50% 50% no-repeat rgb(249,249,249);
}
</style>
<div class="loader"></div>
但沒有結果。
嗨馬丁。你能解釋ajaxStart和ajaxStop功能嗎?這段代碼是否與特定的庫或插件相關,或者您是否打算編寫這些代碼? –
從jQuery 1.9開始,jQuery全局Ajax事件的所有處理程序(包括使用'.ajaxStart()'方法添加的處理程序)必須附加到'document' - [** Docs **](https:// api .jquery.com/ajaxStart /) –