Ajax刷新列表 ajax菜鸟求助
帮帮忙
下面是我要刷新的列表,图片上有说明
这是我取到打印出来的数据格式,
我的ajax代码
var req ;
function createXDOM() {
req = new XMLHttpRequest();
var customer_id = $('#CUSTOMER_ID').val();
var url = "${ctx}/basedata/CustomerInfoAction!AjaxPer.action?id="+customer_id;
req.open("post",url,true);
req.send();
req.onreadystatechange=getInfoByName;
}
function getInfoByName() {
if(req.readyState==4){
//$('#contactList tr').remove();
var list = '${contactPersonInfo}';
alert(list);
/*
var html ='<c:forEach items="${contactPersonInfo}" var="contact">' +
'<tr>' +
'<td>'+($('#contactList tr').length+1)+'</td>' +
'<td>${contact.CUSTOMER_NAME}</td>' +
'<td>${contact.CUSTOMER_SEX}</td>' +
'<td>${contact.CUSTOMER_PROFESSION}</td>' +
'<td>${contact.CUSTOMER_CELL_PHONE}</td>' +
'<td>${contact.CUSTOMER_PHONE}</td>' +
'<td>${contact.CUSTOMER_ADDRESS}</td>' +
'<td>${contact.CUSTOMER_ZIP}</td>' +
'<td>${contact.CUSTOMER_HOBBY}</td>' +
'<td>${contact.CUSTOMER_EASY_TIME}</td>' +
'<td>${contact.CUSTOMER_EASY_CONTACT}</td>' +
'<td>否</td>' +
'</tr>'
'</c:forEach>'
*/
}
$('#contactList').before(html);
}
javascript? Ajax HTML
<table width="100%" border="0" style="margin-top: 0px"
cellpadding="0" cellspacing="0" class="tablel2" id="contacts">
<thead class="tittle_bg">
<tr>
<td>序号</td>
<td>联系人姓名</td>
<td>性别</td>
<td>职务</td>
<td>联系人手机</td>
<td>固定电话</td>
<td>联系人地址</td>
<td>邮编</td>
<td>爱好</td>
<td>方便联系时间</td>
<td>方便联系方式</td>
<td>是否主联系人</td>
</tr>
</thead>
<tbody id="contactList">
<c:choose>
<c:when test="${empty contactPersonInfo}">
<tr id="contactempty">
<td align="center" colspan="20">
<font color="red" >对不起,查到0条数据...</font>
</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach items="${contactPersonInfo}" var="contact">
<tr id="contactTr">
<td>${contact.ROWNUM}</td>
<td>
<a href="#" onclick="showDetailPon(this)" >${contact.CUSTOMER_NAME}</a>
<input type="hidden" name="contactId" value="${contact.RELATIONSHIP_ID}" />
</td>
<td>${contact.CUSTOMER_SEX}</td>
<td>${contact.CUSTOMER_PROFESSION}</td>
<td>${contact.CUSTOMER_CELL_PHONE}</td>
<td>${contact.CUSTOMER_PHONE}</td>
<td>${contact.CUSTOMER_ADDRESS}</td>
<td>${contact.CUSTOMER_ZIP}</td>
<td>${contact.CUSTOMER_HOBBY}</td>
<td>${contact.CUSTOMER_EASY_TIME}</td>
<td>${contact.CUSTOMER_EASY_CONTACT}</td>
<c:if test="${contact.MIAN_CONTACT==1}">
<td>是</td>
</c:if>
<c:if test="${contact.MIAN_CONTACT==0||contact.MIAN_CONTACT==null}">
<td>否</td>
</c:if>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
</tbody>
</table>