• 文件上传(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

  • 相关阅读:
    【Linux高频命令专题(19)】vi/vim
    【Linux高频命令专题(18)】tail
    【Linux常识篇(1)】所谓的正向代理与反向代理
    【nginx运维基础(2)】Nginx的配置文件说明及虚拟主机配置示例
    【nginx运维基础(1)】Nginx的编译安装与使用
    Linux之SAMBA共享服务
    【Linux高频命令专题(17)】head
    【mongoDB高级篇③】综合实战(1): 分析国家地震数据
    php post
    python简单的socket 服务器和客户端
  • 原文地址:https://www.cnblogs.com/weilantiankong/p/6069681.html
Copyright © 2020-2023  润新知