这是我主页面中的内嵌页面,但是当我通过内嵌页面中的ajax提交表单刷新当前页面后,刷新出来的页面就不能通过jquery来获取form了,不知道什么原因  求解
<%@ page contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script>
rArray = new Array(); 
<s:iterator value="orgVoList" status="status">
rArray[<s:property value='#status.index'/>]=new Array("<s:property value='parentOrgId'/>","<s:property value='orgId'/>||<s:property value='orgName' escape='false'/>||");
</s:iterator>
function showParentOrgNameStr(parentId,name,divName){
if(parentId=="" || parentId=="0"){
document.getElementById(divName).innerHTML=name;
}else{
var idStr = "";
for (i = 0 ;i <rArray.length;i++){
tmpRArray = rArray[i][1].split("||"); 
if(tmpRArray[0] == parentId){
idStr = rArray[i][0];
if(name == "")
name = tmpRArray[1];
else
name = (tmpRArray[1]+"-"+name);
break;
}
}
return showParentOrgNameStr(idStr,name,divName);
}
}
</script>
<div id="searchDiv" class="searchDiv">
<div class="searchCondition">
<form name="searchConditionForm" id="searchConditionForm" action="/baseInfo/addUserInfo.action" method="post">
<table id="tab" border="0" style="width: 100%; margin-top: 3px;">
<tbody>
<tr>
<td colspan="6" align="center">
<label id="tip" style="color:red;">
<s:property value="message"/>
</label>
</td>
</tr>
<tr>
<td style="text-align: right;">
<label> 类别: </label>
</td>
<td>
<select id="userType" name="userVo.userType" onchange="userTypeChange()">
<option value="1">系统管理</option>
<option value="2">管理用户</option>
<option value="3">浏览用户</option>
</select>
</td>
</tr>
<tr style="display: none" id="dis">
<td style="text-align: right;">
<label> 机构级别: </label>
</td>
<td style="text-align: left; padding-left: 5px;">
<select id="orgType" name="orgVo.orgType" onchange="orgTypeChange()">
<s:iterator value="baseInfoVoList">
<option value="<s:property value="baseOrder"/>">
<s:property value="baseName" />
</option>
</s:iterator>
</select>
<s:iterator value="baseInfoVoList" status="st">
<select id='orgType<s:property value="#st.index+1"/>' name='orgType<s:property value="#st.index+1"/>' style="display: none" onchange="selectChange(<s:property value="#st.index+1"/>,this.options[this.selectedIndex].value)">
<option value='-1'>请选择</option>
</select>
</s:iterator>
</td>
</tr>
<tr id="file">
<td style="text-align: right;">
<label> 上传文件: </label>
</td>
<td colspan="1" style="text-align: left; padding-left: 5px;">
<input type="file" name="upload" value="" class="text-input" style="" />
</td>
</tr>
<tr id="userName" style="display: none">
<td style="text-align: right;">
<label> 用户姓名: </label>
</td>
<td colspan="1" style="text-align: left; padding-left: 5px;">
<input type="text" id="name" name="userVo.userName" class="text-input"/>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="1" align="center" style="height: 50px;">&nbsp;</td>
<td colspan="2" align="center" style="height: 50px;">
<div id="submitSearchBtn" class="searchBtnDefault" style="margin-left: 90px; width: 68px; height: 22px; float: left; cursor: pointer;"></div>
<div id="resetSearchFormBtn" class="resetBtnDefault" style="margin-right: 90px; width: 68px; height: 22px; float: right; cursor: pointer;"></div>
</td>
<td colspan="1" align="center" style="height: 50px;">&nbsp;</td>
</tr>
</tfoot>
</table>
<input type="hidden" name="orgId" id="orgid">
<input type="hidden" name="userId" id="userid">
<input type="hidden" name="boxs" id="box">
</form>
</div>
<div class="clear"></div>
</div>
<!-- 统计图 -->
<!-- 统计图end -->
<div id="contentDiv" class="contentDiv">
<!-- 用户数据列表 -->
<div id="dataTable" style="width: 100%; float: left;">
<table style="" border="0">
<thead>
<tr>
<th width="16" style="text-align: center;">
<input class="check-all" type="checkbox"/>
</th>
<th width="50" style="text-align: center;">
序号
</th>
<th style="text-align: center;" data-orderBy="hc.channelName">
用户姓名
</th>
<th style="text-align: center;" data-orderBy="hc.channelName">
类别
</th>
<th style="text-align: center;" data-orderBy="hc.parentId">
所属机构
</th>
<th style="text-align: center;">
操作
</th>
</tr>
</thead>
<tbody>
<s:iterator value="pageUserInfoList" status="st">
<tr>
<td width="16" style="text-align: center;">
<input type="checkbox" name="box" value="<s:property value='userId'/>" />
</td>
<td width="50" style="text-align: center;">
<s:property value="#st.index+pageIndex"/>
</td>
<td style="text-align: center;">
<s:property value="userName"/>
</td>
<td style="text-align: center;">
<s:if test="userType==1">
系统管理
</s:if><s:elseif test="userType==2">
管理用户
</s:elseif><s:elseif test="userType==3">
浏览用户
</s:elseif>
</td>
<td style="text-align: center;">
<span id="orgNamesStr<s:property value="#st.index"/>">
<s:property value='parentOrgId'/>
</span>
<script>
showParentOrgNameStr("<s:property value='parentOrgId'/>","<s:property value='OrgName'/>","orgNamesStr<s:property value='#st.index'/>");
</script>
</td>
<td style="text-align: center;">
<a style="color: red;" href="#" onclick="up('<s:property value='orgType'/>','<s:property value='userId'/>','<s:property value='userName'/>','<s:property value='orgId'/>','<s:property value='userType'/>')">更新</a>
/
<a style="color: red;" href="#" onclick="del()">删除</a>
</td>
</tr>
</s:iterator>
</tbody>
<tfoot>
<tr>
<td colspan="11">
<div
style="float: left; width: 150px; position: relative; padding: 20px 0 20px 0;">
</div>
<div id="pageInfoDiv" class="pagination">
<a href="javascript:gotoPage(1,'baseInfo/userInfo.action')" title="First Page">&laquo; 首页</a> 
<a href="javascript:gotoPage(<s:property value='pageNow-1'/>,'baseInfo/userInfo.action')" title="Previous Page">&laquo; 上页</a>
<s:set name="pageSum" value="pageSum" />
<s:set name="pageNow" value="pageNow" />
<%
int pageSum = (Integer) pageContext.getAttribute("pageSum");
int pageNow = (Integer) pageContext.getAttribute("pageNow");
for (int i = 1; i <= pageSum; i++) {
out.print("<a href=\"javascript:gotoPage("+i+" , \'baseInfo/userInfo.action\')\" class=\""+(i == pageNow ? "number current" : "number")+"\" title=\"" + i + "\"> " + i + "</a>");
}
%>
<a href="javascript:gotoPage(<s:property value='pageNow+1'/>,'baseInfo/userInfo.action')" title="Next Page">下页 &raquo;</a>
<a href="javascript:gotoPage(<s:property value='pageSum'/>,'baseInfo/userInfo.action')" title="Last Page">尾页 &raquo;</a>
</div> 
<!-- End .pagination -->
<div style="clear: both;"></div>
</td>
</tr>
</tfoot>
</table>
</div>
<!-- 用户数据列表 结束 -->
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>

解决方案 »

  1.   

    <style>
    .searchDiv {
    float: left;
    width: 980px;
    height: auto !important;
    height: 250px;
    min-height: 250px;
    line-height: 16px;
    }.statisticDiv {
    float: left;
    width: 980px;
    height: auto !important;
    height: 320px;
    min-height: 320px;
    line-height: 16px;
    margin-top: 10px;
    }.contentDiv {
    float: left;
    width: 980px;
    height: auto;
    margin-top: 10px;
    line-height: 16px;
    overflow-y: auto;
    }#dataTable table {
    border-collapse: collapse;
    margin: 0px auto;
    color: #3b597a;
    border: 1px solid #8abae0;
    }#dataTable table thead th {
    font-weight: bold;
    font-size: 14px;
    border-bottom: 1px solid #8abae0;
    height: 18px;
    line-height: 18px;
    background: #d4e6f4;
    }#dataTable tbody {
    border-bottom: 1px solid #8abae0;
    }#dataTable tbody tr {
    background: #fff;
    }#dataTable tbody tr.alt-row {
    background: #e6f0f9;
    }#dataTable table td,#dataTable table th {
    padding: 6px;
    line-height: 1.3em;
    }#dataTable table tfoot td .bulk-actions {
    padding: 15px 0 5px 0;
    }#dataTable table tfoot td .bulk-actions select {
    padding: 4px;
    border: 1px solid #ccc;
    }#dataTable .pagination {
    text-align: right;
    padding: 20px 0 20px 0;
    font-size: 12px;
    }.pagination a {
    margin: 0 5px 0 0;
    padding: 3px 6px;
    color: #3b597a;
    }.pagination a.number {
    border: 1px solid #ddd;
    }.pagination a.current {
    background: #00529b url("images/bg-button-blue.gif") top left repeat-x
    !important;
    border-color: #00529b !important;
    color: #fff !important;
    }.pagination a.current:hover {
    text-decoration: underline;
    }
    </style>
    <script type="text/javascript">
    var questionDialog = "";
    var form;
    $(function() {
    $("#submitSearchBtn").hover(function() {
    $(this).removeClass("searchBtnDefault").addClass("searchBtnHover");
    }, function() {
    $(this).removeClass("searchBtnHover").addClass("searchBtnDefault");
    });
    $("#resetSearchFormBtn").hover(function() {
    $(this).removeClass("resetBtnDefault").addClass("resetBtnHover");
    }, function() {
    $(this).removeClass("resetBtnHover").addClass("resetBtnDefault");
    });
    //添加table样式
    $('tbody tr:even').addClass("alt-row");
    //提交检索条件
    $("#submitSearchBtn").click(function() {
    $("#searchConditionForm").submit();
    });
    $("#searchConditionForm").ajaxForm( {
    dataType : 'html',
    beforeSubmit : function(formData, jqForm, options) {
    },
    success : function(msg) {
    alert("#mainContent:"+$("#mainContent").attr("id"));
    $("#mainContent").html(msg);
    }
    });
    //复位form
    /*
    $("#resetSearchFormBtn").click(function() {
    questionDialog = new $.Zebra_Dialog('您确定要重置表单吗? ', {
    'title' : '重置表单',
    'type' : 'question',
    'overlay_opacity' : .3,
    'buttons' : [ {
    caption : '确定',
    callback : function() {
    $("#searchConditionForm").reset();
    }
    }, {
    caption : '取消',
    callback : function() {
    questionDialog.close();
    }
    } ],
    'overlay_close' : false
    });
    });
    */
    $('.check-all').click(
    function() {
    $(this).parent().parent().parent().parent().find("input[type='checkbox']").attr('checked',
    $(this).is(':checked'));
    });
    });

    function selectChange(j,selectId){
    var selectValue = document.getElementById("orgType").value;
    for (i = (parseInt(j)+1) ;i <document.getElementById("orgType").length;i++){ 
    document.getElementById("orgType".concat(i)).length = 1;
    document.getElementById("orgType".concat(i)).options[0] = new Option("请选择","-1"); 
    }
    var cnt=1;
    for (i = 0 ;i <rArray.length;i++){ 
    if(rArray[i][0]==selectId){
    tmpRArray = rArray[i][1].split("||");
    if( parseInt(j) < parseInt(document.getElementById("orgType").length)+1)
    document.getElementById("orgType".concat(j+1)).options[cnt++] = new Option(tmpRArray[1],tmpRArray[0]); 
    }
    }
    var i=parseInt(selectValue);
    var type=document.getElementById("orgType"+i).value;
    document.getElementById("orgid").value=type;
    } function up(orgtype,userid,username,orgid,usertype) {
    var url="/baseInfo/upUserOrgInfo.action";
    var name=document.getElementById("userName");
    var userId=document.getElementById("userid");
    var file=document.getElementById("file");
    var dis=document.getElementById("dis");
    var orgType=document.getElementById("orgType");
    var userType=document.getElementById("userType");
    userId.value=userid;
    document.getElementById("name").value=username;
    name.style.display="";
    file.style.display="none";
    orgType.value=orgtype;
    userType.options[parseInt(usertype)-1].selected=true;
    document.getElementById("searchConditionForm").action=url;
    if(usertype!=1) {
    dis.style.display="";
    orgTypeChange();
    selectValue(orgtype,orgid);
    }else{
    dis.style.display="none";
    }
    }
    function del() {
    var userid="";
    var arr=document.getElementsByName("box");
    for(var i=0;i<arr.length;i++) {
    if(arr[i].checked){
        userid+=arr[i].value+",";
        }
    }
    var url="/baseInfo/delUser.action";
    document.getElementById("searchConditionForm").action=url;
    document.getElementById("box").value=userid;
    $("#searchConditionForm").ajaxSubmit();
    }

    function selectValue(x,y){
    document.getElementById("orgid").value=y;
    var i=parseInt(x);
    var orgid=y;
    if(i!=0) {
    for(var z=0;z<document.getElementById("orgType").length;z++) {
    for(var j=0;j<rArray.length;j++) {
    tmpRArray = rArray[j][1].split("||");
    if(tmpRArray[0]==orgid) {
    document.getElementById("orgType".concat(i)).options[0] = new Option(tmpRArray[1],tmpRArray[0]); 
    document.getElementById("orgType".concat(i)).options[0].selected=true;
    orgid=rArray[j][0];
    i--;
    }
    }
    }
    }
    }

    function userTypeChange() {
    var n =$("#userType").val();
    if(n=="1") {
    document.getElementById("dis").style.display="none";
    }else{
    document.getElementById("dis").style.display="";
    }
    } function orgTypeChange() {
    var selectState = document.getElementById("orgType");
    var selectLength = parseInt(selectState.length);
    if (selectState.length > 0) {
    for ( var i = 0; i <selectLength; i++) {
    if (selectState.options[i].selected==true) {
    var selectValue =selectState.options[i].value;
    for ( var j = 1; j <=selectValue; j++) {
    document.getElementById("orgType".concat(j)).style.display = "";
    }
    for ( var j = parseInt(selectValue); j < selectLength ; j++) {
    document.getElementById("orgType".concat(j+1)).style.display = "none";
    }
    selectChange(0,"0");
    }
    }
    }
    }
    $(document).ready(function() {
    orgTypeChange();
    userTypeChange();
    });
    </script>