文件上传进度条实现

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

文件上传进度条

实现工具

jquery.form

参数说明

uploadProgress
Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments:
1.) event; the browser event
2.) position (integer)
3.) total (integer)
4.) percentComplete (integer)
Default value: null

功能实现

	$("#"+modal+" form").ajaxSubmit({
        type:'post',
        url:"url",
        complete:function(){
            
        },
        beforeSend: function() {
            // 初始化进度条
        	$("#"+modal+" .progressBar").show();
            var percentVal = '0%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
        uploadProgress: function(event, position, total, percentComplete) {//上传的过程
            var percentVal = percentComplete + '%';
            bar.width(percentVal);
            percent.html(percentVal);
        },
        success:function(data){
            
        },
        error:function(XmlHttpRequest,textStatus,errorThrown){
        	
        }
    });

转载于:https://my.oschina.net/shichangcheng/blog/1580208

你可能感兴趣的:(python,javascript)