数据表未显示行的子项

时间:2018-04-26 18:39:34

标签: javascript php jquery datatable

加载子行的Jquery代码:

function format ( d ) {
    // `d` is the original data object for the row
    var div = $('<div/>')
        .addClass( 'loading' )
        .text( 'Loading...' );
	
	var product_id = d['DT_RowId'];//This is the ItemId
	var btn_action = 'item_detail';	
	
    $.ajax( {
        url: 'item_action.php', //Calling the function
        data: {
            product_id:product_id, 
			btn_action:btn_action //Set item_id and variable se
        },
        dataType: 'json',
        success: function ( test ) {
            div
                .html( data.html )
                .removeClass( 'loading' );
        }
    } );
 
    return div;
}
<!-- HTML Code -->

<table id="item_data" class="table table-bordered table-striped">
	<thead>
		<tr>
			<th></th>
			<th>Item Code</th>
			<th>Item Description</th>
			<th>Product Line</th>									
			<th>Purchase Standard Cost</th>
			<th>Last Receipt</th>									
			<th>Status</th>									
			<th></th>
			<th></th>
			<th></th>
		</tr>
</thead>																	
</table>

<!-- PHP Code -->
<?php

$data = array();
		$data[]='<table class="table table-bordered table-striped dataTable no-footer" cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;"';		
		foreach($result as $row)//Fill the table cells
		{			
			$output .= '
			<tr>
				<td>Price Code</td>
				<td>'.$row["pricecode_code"].'</td>
			</tr>			
			';
			$subarray[]=$output;
			$data[] = $sub_array;
		}	
		$data[]='</table>';
		$output = array(
		"draw"    			=> 	intval($_POST["draw"]),			
		"html"    			=> 	$data
		);		
		echo json_encode($output); //Return the table formatted 		
?>

当我点击详细信息时,它会添加Loading Class但不显示详细信息!错误在哪里?

0 个答案:

没有答案