【问题标题】:How to use the Materialize linear indeterminate progress bar as a page preloader?如何使用 Materialise 线性不确定进度条作为页面预加载器?
【发布时间】:2020-05-23 16:36:15
【问题描述】:
【问题讨论】:
标签:
javascript
html
css
progress-bar
materialize
【解决方案1】:
Circular 和 Linear Indeterminate 预加载器没有附加任何逻辑 - 它们只是动画、循环、永远。开发人员可以根据需要显示和隐藏。
这是一个示例,说明如何在 ajax 调用中使用它们 - 显示调用何时触发,然后在成功时隐藏:
function ajax_function() {
$('.preloader-wrapper').removeClass('hide');
$.ajax({
url : '.../wp-admin/admin-ajax.php',
type : 'post',
data : {
data: mydata
},
error : function( response ){
// Handle error
},
success : function( response ){
if( response == 0 ) {
// Handle no response
} else {
$('.mydiv').append( response );
$('.preloader-wrapper').addClass('hide');
}
}
})
}