Fling_Cui 2017-01-19 03:23 采纳率: 100%
浏览 2560
已采纳

jQuery执行完成之后,页面异常刷新 执行完一个输入框的回车事件代码之后,会自动刷新页面

 function queryFundSelect(WidgetId,inputId,inputName){
        var html = "";
        html += '<div class="p_c_pull align_left">';
        html += '<input type="text" id="'+inputId+'View" class="input_box_pull" value="全部产品" onkeyup="fuzzyQuery(event,$(this),\''+WidgetId+'\',\''+inputId+'\');" />';
        html += '<ul class="p_c_box">';
        html += '<li><a href="javascript:;" onclick="setInput_box_pull($(this),\''+inputId+'\',\''+''+'\');">全部产品</a></li>';
        $.each(fuzzyQueryMap.data, function(key, value) {
            html += '<li><a href="javascript:void(0);" onclick="setInput_box_pull($(this),\''+inputId+'\',\''+ key +'\');">' + value +'</a></li>';
        });
        html += '</ul>';
        html += '<input type="hidden" id="'+inputId+'" name="'+inputName+'" class="input_box_pull" />';
        html += '</div>';
         $("#"+WidgetId).html(html);
         $(".p_c_box").niceScroll({  
            cursorcolor:"#949dac",  
            cursoropacitymax:1,  
            touchbehavior:false,  
            cursorwidth:"5px",  
            cursorborder:"0",  
            cursorborderradius:"5px"
        });             
    }
 function fuzzyQuery(e,$_this, target, inputId) {
        var values =$_this.val();
        if(e.keyCode==13){
            $("#"+inputId+"View").val(values);
            $("#"+inputId).val(values);
            $_this.parent().parent(".p_c_box").hide();
            $_this.parent().parent().parent(".p_c_pull").find(".input_box_pull").removeClass("on");
            queryRedeemFund();
            $("#"+inputId+"View").off("onkeyup");   
        }else{
            values = values.toUpperCase();
            var reg = new RegExp(values);
            var html = "";
            html += '<li><a href="javascript:;" onclick="setInput_box_pull($(this),\''+inputId+'\',\''+''+'\');">全部产品</a></li>';
            $.each(fuzzyQueryMap.data, function(key, value) {
                 if (value.indexOf(values)!=-1) {
                    value = value.replace(reg, "<span style='color:#ff4646'>" + values + "</span>");
                    html += '<li><a href="javascript:;" onclick="setInput_box_pull($(this),\''+inputId+'\',\''+key+'\');">'+value+'</a></li>';
                 }
             });
            $("#"+target+" .p_c_box").html(html);   
        }   
    }
 function queryRedeemFund() {
        var aoData = $("#search_form").serializeArray();
        $.ajax({
            url:"${pageContext.request.contextPath}/trade/redeemFundAction_loadDataTable.do",
            cache :false,
            data:aoData,
            dataType:"json",
            async:false,
            success:function(data) {
                if (data.retcode == '<%= SysConst.RETURNCODE_SUCCESS%>') {
                    var resultBodyHtml = createResultBodyHtml(data);
                    var htmlHead = "<tr><th style='width:5%'>产品类型</th><th style='width:13%'>产品名称</th><th style='width:9%'>支付账户</th><th style='width:10%'>到期日</th><th style='width:9.5%'>净值</br><span class='s_center' style='font-size:10px'>"+resultBodyHtml[1]+"</span></th><th style='text-align:left;width:7.5%'>约定预期年化</th><th style='text-align:right;width:10%'>可用份额</th><th style='text-align:right;width:10%'>已预约份额</th><th style='text-align:right;width:13%'>参考市价</th><th style='width:13%'>操作</th></tr>";
                    if (isNull(resultBodyHtml[0])) {
                        resultBodyHtml[0] += "<tr>";
                        var branchCode = '<s:property value="#session.user.custInfo.branchCode"/>';
                        var info = '您尚未在直销渠道持有该产品';
                        if (branchCode == <%=SysConst.BRANCHCODE_1%>) {
                            info = '直销柜台交易份额仅供查询';
                        }
                        resultBodyHtml[0] += "<th class='name' colspan='10' style='text-align:center'>" + info + "</th>";
                        resultBodyHtml[0] += "</tr>";
                        $("#result_tbody_fund").html(resultBodyHtml[0]);
                    } else {
                        $("#result_tbody_fund").html(htmlHead + resultBodyHtml[0]);
                    }
                    initIframeDivH("#divmain","#mainFrame");
                }
            }
        });
    }
 <form action="" id="search_form" method="post">
    <table class="pro_tb" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td><span class="s_ft2">持有产品筛选:</span></td>
                <td id="fundCode"></td>
            </tr>
    </table>
</form>
  • 写回答

5条回答 默认 最新

  • Fling_Cui 2017-01-19 06:04
    关注

    确实是回车事件和表单submit提交冲突了,可以在页面上再加个input标签 然后隐藏掉

    就可以了!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题