zoukankan      html  css  js  c++  java
  • 关于jq ajax封装以及ajax上传Webapi

     jq的ajax完整版本

    $(function () {
        fileChange();
    });
    function fileChange() {
        $('#fileinput').change(function () {
            ajaxUploadImg();
        });
    }

    function ajaxUploadImg() {
        var formData = new FormData($('#idcardA')[0]);
        $.ajax({
            url: appObj.baseApiUrl + '/userinfo/UploadIDCardInfo',  //server script to process data
            type: 'POST',
            datatype: 'json',
            contentType: false,
            xhr: function () {  // custom xhr
                myXhr = $.ajaxSettings.xhr();
                if (myXhr.upload) { // check if upload property exists
                    myXhr.upload.addEventListener('progress', progressHandlingFunction, false); // for handling the progress of the upload
                }
                return myXhr;
            },
            //Ajax事件
            //beforeSend: beforeSendHandler,
            success: function (data) {
                $('#idCardimg').attr('src', appObj.baseUrl + data);
            },
            error: function () {
                alert('error');
            },
            // Form数据
            data: formData,
            //Options to tell JQuery not to process data or worry about content-type
            cache: false,
            processData: false
        });
    }

    上传身份证正面照片:
                        <form id="idcardA" enctype="multipart/form-data">
                            <input id="fileinput" name="file" type="file" />
                        </form>

  • 相关阅读:
    pointer-net
    pytorch0.4版的CNN对minist分类
    python+selenium遍历某一个标签中的内容
    selenium提取不了标签文本
    IndentationError: unindent does not match any outer indentation level
    windows下载安装mysql
    引用opencv异常
    jenkins简单安装及配置(Windows环境)
    多台服务器-SSH免密登录设置
    scheduleAtFixedRate 与 scheduleWithFixedDelay 的区别
  • 原文地址:https://www.cnblogs.com/tdws/p/4293474.html
Copyright © 2011-2022 走看看