可根据table中某列中的ID去改变某列的值!
只是参考,实际应用中不能这样做的,如果有很多行,频繁访问服务器,服务器是顶不住的!
JS:
$(document).ready(function () {
setTimeout(GetDate, 1000); }); function GetDate() {
$("#tbData tbody").find("tr").each(function () {
var prjectBalanceObj = $(this).find("td:eq(3)");
var xmbhObj = $(this).find("td:eq(0)").html();
$.ajax({
type: "get",
async: true,
url: "ashx/GetData.ashx?id=" + $(this).find("td:eq(1)").html(),
contentType: "application/x-www-form-urlencoded; charset=utf-8",
beforeSend: function (XMLHttpRequest) {
},
success: function (data, textStatus) { prjectBalanceObj.html(data); },
complete: function (XMLHttpRequest, textStatus) {
//alert("XMLHttpRequest:" + XMLHttpRequest + "--textStatus" + textStatus);
},
error: function () {
//alert("获取数据出错");
}
});
}) }
HTML:
<h2>Jquery Ajax 异步设置Table某列的值</h2>
<table class="bordered" id="tbData" >
<thead> <tr>
<th>No</th>
<th>ID</th>
<th>名称</th>
<th>金额</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>001</td>
<td>编码1</td>
<td></td>
</tr>
<tr>
<td>2</td>
<td>002</td>
<td>编码2</td>
<td></td>
</tr>
<tr> <td>3</td>
<td>003</td>
<td>编码3</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>004</td>
<td>编码4</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>005</td>
<td>编码5</td>
<td></td>
</tr>
</tbody>
</table>
效果:
(VS2010)源码:
http://files.cnblogs.com/files/longwu7456/Jquery_Ajax_Table_Demo.rar