English 中文(简体)
删除 AJAX 的表格行
原标题:Delete table rows with AJAX

I m 使用 AJAX 从 jQuery Datatable 中删除特定的行。 这些行在第十列中值为0( 如果我们开始从 0 开始计算的话)。 在下面您可以看到我的代码。 出于某种原因, 它不会删除任何行。 我检查了 aData[ 10] \\ gt 的值; 在一些行中, 它的定义等于 0 。

     $(document).ready(function(){
          $( #newspaper-b ).dataTable({
          "sPaginationType":"full_numbers",
          "aaSorting":[[4, "asc"]],
          "aoColumns": [null,null,null,null,null,null,null,null,null,null,
                        {"bSearchable": true, "bVisible": false},null,null],
          "bJQueryUI":true,
           fnRowCallback : function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                if(aData[10]=="0"){
                    $(nRow).remove();
                }
                return nRow;
            }
          });

最新更新

当我这样做时:

 fnRowCallback : function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                      var r=confirm(aData[10]);
                  if (parseInt(aData[10], 10) === 0) {
                        $(nRow).remove();
                    }
                    return nRow;
                }

...then I can see that one of rows has 0. But when I do this:

 fnRowCallback : function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                  if (parseInt(aData[10], 10) === 0) {
var r=confirm(aData[10]);
                        $(nRow).remove();
                    }
                    return nRow;
            }

...然后通知联署材料信息(即var r=confirm(aData[10]) )没有出现,这意味着IF声明是虚假的。 但为什么呢?

! [在此输入图像描述 [1]

问题回答

这可能是一个打字问题。 尝试将列值转换成像这样的整数 :

if (parseInt(aData[10], 10) === 0) {
    $(nRow).remove();
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签