我對服務器(C#)一個循環,這樣處理:使用jQuery的表格操作 - 行數是關閉
for(i=0;i<=Request.Files.Count - 1; i++)
{
// tell the client that the upload is about to happen
// and report useful information
Update(percent, message, i, 0);
System.Threading.Thread.Sleep(1000);
// tell the client that upload succeeded
// and report useful information
Update(percent, message, i, 1);
}
「更新」寫入到客戶端的JavaScript函數「PublishUpdate」功能。 行參數是包含上傳文件的表中的行。 '狀態'告訴我們文件即將被上傳(0)還是完成(1)。
問題是,我似乎無法得到正確的計數。循環似乎在 開始2或3行放入表中或(在播放行值後)它在 最後一行之前結束。我對jQuery非常陌生。有什麼東西看起來顯然是錯的嗎?
function PublishUpdate(percent, message, row, status)
{
var bodyRows = $("#picTableDisplay tbody tr");
bodyRows.each(function(index){
if (index == row && status == 0)
$('#status'+index).html("<img alt='inproc' src='images/loading.gif' />");
else if (index == row && status == 1)
$('#status'+index).html("complete");
});
}
最後,表看起來是這樣的:提前
<table width="100%" cellspacing="0" cellpadding="3" border="0" align="center" id="picTableDisplay" summary="" class="x-pinfo-table">
<tbody id="files_list" class="scrollContent">
<tr class="evenRow">
<td class="numCol" id="num0">
</td>
<td class="fnameCol" id="fname0">
</td>
<td class="statusCol" nowrap="" id="status0">
</td>
<td class="remCol" id="rem0">
</td>
</tr>
<tr class="oddRow">
<td class="numCol" id="num1">
</td>
<td class="fnameCol" id="fname1">
</td>
<td class="statusCol" nowrap="" id="status1">
</td>
<td class="remCol" id="rem1">
</td>
</tr>
<tr class="evenRow">
<td class="numCol" id="num2">
</td>
<td class="fnameCol" id="fname2">
</td>
<td class="statusCol" nowrap="" id="status2">
</td>
<td class="remCol" id="rem2">
</td>
</tr>
AND SO ON ...
感謝。
爲什麼有')'後,關閉大括號? – kiamlaluno 2009-12-20 23:06:16
要完成.each( – Rich 2009-12-20 23:07:42
但最後}缺失! – Rich 2009-12-20 23:08:13