2017-05-29 14 views
1

データテーブルのプラグインを使用してデータをページ付けしようとしていますが、ページングの作業は初めてです。まず、そのページの2番目のページをクリックするとデータが表示されますが、その後は表示されません。それはここに私のコードですテーブルの上部に処理を示しています。最初のページングのみのデータシートのページ設定作業

HTML

<table id="data_table" class="display" width="100%" cellspacing="0"> 
    <thead> 
     <tr> 
      <th><input type="checkbox" id="selectAll"/></th> 
      <th>Plan Name</th> 
      <th>Description</th> 
      <th>Image</th> 
      <th>Quantity</th> 
      <th>Amount</th> 
      <th>Action</th> 
     </tr> 
    </thead> 
    <tbody></tbody> 
</table> 

jQueryの

$("#data_table").dataTable({ 
    "bProcessing": true, 
    "bServerSide": true, 
    "bPaginate": true, 
    "sAjaxSource": "response.php", 
}); 

PHP

if(isset($_GET['iDisplayStart'])) 
    { 
     $start = $_GET['iDisplayStart']; 
    } 
    else 
    { 
     $start = 0; 
    } 

    if(isset($_GET['iDisplayLength'])) 
    { 
     $limit = $_GET['iDisplayLength']; 
    } 
    else 
    { 
     $limit = 10; 
    } 

    $plan = new Plan(); 
    $result = $plan->getPlanList($limit, $start); 
    $count= $plan->getCountPlanList(); 
    $myarray['recordsTotal'] = $count[0]['count(*)']; 
    $myarray['recordsFiltered'] = $count[0]['count(*)']; 
    $myarray['draw'] = intval($start/$limit)+1; 
    $myarray['data'] =""; 
    foreach($result as $data) 
    { 
     $myarray['data'][] = array('<input type="checkbox" name="selectcheck[]" class="selectcheck" value="'.$data['id'].'">',$data['name'],$data['description'],$data['image'],$data['quantity'],$data['amount'],'<a href="">Edit</a>'); 
    } 

    echo json_encode($myarray); 
    die; 
+1

ブラウザのコンソールにエラーが発生していますか? –

+0

コンソールでエラーが発生しません。コンソール上でリクエストをサーバに送信してデータを取得しますが、データは描画されません –

+0

'' pagingType '': '' full_numbers''を追加する必要があります –

答えて

1

解決の問題。サーバー側の描画でsEcho値を使用する

$myarray['draw'] = $_GET['sEcho']; 
関連する問題