Javascript ajax调用完成后无法删除进度条
我做错了什么Javascript ajax调用完成后无法删除进度条,javascript,jquery,ajax,Javascript,Jquery,Ajax,我做错了什么 progressbar : function() { var $progress = $('<div>', {'class' : 'progress-bar', height : '2px'}); var width = 0, load = 0; $(document).on({ ajaxSend : function(event, req, set) { $('body').appe
progressbar : function() {
var $progress = $('<div>', {'class' : 'progress-bar', height : '2px'});
var width = 0,
load = 0;
$(document).on({
ajaxSend : function(event, req, set) {
$('body').append($progress);
load = setInterval(function(e) {
if (width > 100) {
clearInterval(load);
}
width++;
$('.progress-bar').width(width + '%');
}, 10);
},
ajaxComplete : function(){
width = 0;
clearInterval(load);
$('body').remove('.progress-bar');
//$('.progress-bar').fadeOut();
}
});
}
progressbar:function(){
var$progress=$(“”,{'class':'progress bar',高度:'2px'});
变量宽度=0,
载荷=0;
$(文档).on({
ajaxSend:功能(事件、请求、设置){
$('body')。追加($progress);
加载=设置间隔(功能(e){
如果(宽度>100){
净距(负荷);
}
宽度++;
$('.progress bar').width(width+'%');
}, 10);
},
ajaxComplete:function(){
宽度=0;
净距(负荷);
$('body')。删除('progress bar');
//$('.progress bar').fadeOut();
}
});
}
淡出功能可以工作,但我无法从DOM中删除.progress条。我在window-load&click上调用上述函数
$('body').remove('.progress-bar');
替换为
$('.progress-bar').remove();
你必须使用
$('.progress bar')。remove()
@krasenslavov很高兴,我帮了你。请务必接受答案,以备将来参考:)