0

データベースの値に基づいて列を表示/非表示にしようとしています。Jquery、PHP、MySQL を使用しています。

データを取得して列を非表示にするために ajax を使用していましたが、tbody データは非表示にならず、ヘッダーのみが非表示になっています。

$(function () 
  {
    //-----------------------------------------------------------------------
    // 2) Send a http request with AJAX http://api.jquery.com/jQuery.ajax/
    //-----------------------------------------------------------------------
    $.ajax({                                      
      url: 'account-number.php',                  //the script to call to get data          
      data: '',                        //you can insert url argumnets here to pass to api.php
                                       //for example "id=5&parent=6"
      dataType: 'json',                //data format      
      success: function(data)          //on recieve of reply
      {
        var user = data[1];              //get id
        var table = data[2];            //get table name 
        var show = data[4];          //display or hide
        //--------------------------------------------------------------------
        // 3) Update html content
        //--------------------------------------------------------------------
        //recommend reading up on jquery selectors they are awesome 
        // http://api.jquery.com/category/selectors/
        if (show == 0)
        $('#'+ table +'tbody td:nth-child(1), #' + table + 'thead th:nth-child(1)').hide();
        //$('#'+ table +'td:nth-child('+ column +'),th:nth-child('+ column +')').hide();
        if (show == 1)
        $('#'+ table +'tbody td:nth-child(1), #' + table + 'thead th:nth-child(1)').show();
      } 
    });
  }); 

このため、コンソールにエラーはありません。データベースの値に基づいてJqueryのデータテーブルでテーブルデータを非表示/表示する特定の方法はありますか?

任意のヘルプや提案をいただければ幸いです。

4

1 に答える 1