Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ajax调用完成后无法删除进度条_Javascript_Jquery_Ajax - Fatal编程技术网

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很高兴,我帮了你。请务必接受答案,以备将来参考:)