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>
答
确实是回车事件和表单submit提交冲突了,可以在页面上再加个input标签 然后隐藏掉
就可以了!
答
在你觉得会出问题的地方断点看下代码执行顺序
答
估计回车事件和表单submit提交冲突了,如果页面有表单,还有一个搜索框那种,就容易出问题
答
看看页面是否有submit按钮,回车会自动调用的
答
多亏这条线索