zoukankan      html  css  js  c++  java
  • javascript 上传进度条

    function upload() {
                    var formData = new FormData(document.getElementById("inputForm"));
                    //创建xhr
                    var xhr = new XMLHttpRequest();
                    var url = "save";
                    xhr.open("POST", url, true);
                    xhr.onreadystatechange = function () {
                        if (xhr.readyState == 4 && xhr.status == 200) {
                            var result = xhr.responseText;
                            document.write(result);
                        }
                        if(xhr.readyState == 4 && xhr.status == 500){
                            var result = xhr.responseText;
                            document.write(result);
                        }
                    };
                    //进度条部分
                    xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】
                    xhr.send(formData);
                }
                function progressFunction(evt){
                    if (evt.lengthComputable) {//
                        loading('正在上传,请您等待...' + Math.round(evt.loaded / evt.total * 100) + "%");
                    }
                }
    
  • 相关阅读:
    干将莫邪
    Rancher
    Rancher 1.6 版本 只能在 linux 下用
    野蛮人大作战
    Oracle
    Gradle
    正则表达式 我遇到的
    Redis
    NestJS 用TypeScript开发 nodeJS后端
    Koa2
  • 原文地址:https://www.cnblogs.com/zxcgy/p/7261496.html
Copyright © 2011-2022 走看看