可根据table中某列中的ID去改变某列的值!
JS:
1 $(document).ready(function () { 2 setTimeout(GetDate, 1000); 3 4 }); 5 6 function GetDate() { 7 $("#tbData tbody").find("tr").each(function () { 8 var prjectBalanceObj = $(this).find("td:eq(3)"); 9 var xmbhObj = $(this).find("td:eq(0)").html(); 10 $.ajax({ 11 type: "get", 12 async: true, 13 url: "ashx/GetData.ashx?id=" + $(this).find("td:eq(1)").html(), 14 contentType: "application/x-www-form-urlencoded; charset=utf-8", 15 beforeSend: function (XMLHttpRequest) { 16 }, 17 success: function (data, textStatus) { 18 19 prjectBalanceObj.html(data); 20 21 }, 22 complete: function (XMLHttpRequest, textStatus) { 23 //alert("XMLHttpRequest:" + XMLHttpRequest + "--textStatus" + textStatus); 24 }, 25 error: function () { 26 //alert("获取数据出错"); 27 } 28 }); 29 }) 30 31 }
HTML:
1 <h2>Jquery Ajax 异步设置Table某列的值</h2> 2 <table class="bordered" id="tbData" > 3 <thead> 4 5 <tr> 6 <th>No</th> 7 <th>ID</th> 8 <th>名称</th> 9 <th>金额</th> 10 </tr> 11 </thead> 12 <tbody> 13 <tr> 14 <td>1</td> 15 <td>001</td> 16 <td>编码1</td> 17 <td></td> 18 </tr> 19 <tr> 20 <td>2</td> 21 <td>002</td> 22 <td>编码2</td> 23 <td></td> 24 </tr> 25 <tr> 26 27 <td>3</td> 28 <td>003</td> 29 <td>编码3</td> 30 <td></td> 31 </tr> 32 <tr> 33 <td>4</td> 34 <td>004</td> 35 <td>编码4</td> 36 <td></td> 37 </tr> 38 <tr> 39 <td>5</td> 40 <td>005</td> 41 <td>编码5</td> 42 <td></td> 43 </tr> 44 </tbody> 45 </table>
效果:
(VS2010)源码:
http://files.cnblogs.com/files/longwu7456/Jquery_Ajax_Table_Demo.rar
时间: 2024-10-14 02:54:49