zoukankan      html  css  js  c++  java
  • 文件上传(excel服务端解析)

    1,html结构

    
    
    <!-- 引入jQuery和jQuery.form.js插件 -->
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.form.js"></script>

    ## 批量上架原因
    <script id="batchOnlineList_tpl" type="text/template"> <form id="J_bachOnlineForm" method="POST" enctype="multipart/form-data"> <div id="J_on"> <div class="jui-form-item fn-mt20"> <label style="106px;" class="jui-input-label"> <span class="jui-label-required">上架:</span> </label> <input id="batchOnlineFileInput" name="file" type="file" class="fn-hide" onchange="document.getElementById('batchOnlineFile').value=this.value"/> <input type="text" name="batchOnlineFile" id="batchOnlineFile" readonly="readonly" /> <a class="jui-btn J_batchOnlineBtn" onclick="jQuery('#batchOnlineFileInput').click();">浏览</a> <div class="jui-form-tip J_onFileTipError">请上传附件,文件类型为.xls,最多处理500家</div> </div> <div class="jui-form-item fn-mt20"> <label style="106px;" class="jui-input-label"> <span class="jui-label-required">原因:</span> </label> <textarea id="J_batchOnlineReason" name="memo" maxlength="200" cols="38" rows="5"></textarea> <div class="jui-form-tip">200字以内<span class="J_onTipError fn-hide fn-ml20;" style="color: red;margin-left: 20px;">原因不能为空</span></div> </div> </div> </form> </script>

    2,js代码

    ajaxSubmit: function (params) {
                    $('#J_bachOnlineForm').ajaxSubmit({
                        type: 'POST',
                        url: params.url,
                        dataType: "JSON",
                        contentType: "application/x-www-form-urlencoded; charset=utf-8",
                        success: params.doData,
                        error: function (res) {
                            params._this.removeDialogLoading();// 去除处理中状态
                            params._this.oBox.hide();// 关闭浮层
                            params.orderNumber.showMessage({
                                state: "error",
                                message: "系统异常"
                            })
                        }
                    });
                }

    3,填坑

    jquery.form.js 中文乱码问题,详情:用ajaxSubmit进行Form Post提交的时候,发现服务器端取回的中文数据居然是乱码。这个可能是因为jquery是utf-8,不支持gb2312

    将js文件中return $(el).val(); 改成return escape($(el).val());然后在服务器端,可以用 Server.UrlDecode() 进行解码,这样乱码就不在出现了

    详见:http://www.111cn.net/wy/jquery/42168.htm

  • 相关阅读:
    jquery下拉菜单打开的同时,同行右边的图标变化
    echarts引入及应用
    好用又美观的时间控件
    C#不支持此安全协议
    python re模块中的函数
    python中的收集参数
    python常用操作符
    python 字符串中常用的内置函数
    VS2012停止工作解决办法
    Jqurey图片放大镜插件
  • 原文地址:https://www.cnblogs.com/weilantiankong/p/6069681.html
Copyright © 2011-2022 走看看