1
我有一個頁面,生成一個表,其內容將被檢索使用.getJSON
。但我有一個變量要通過該條件查詢。這裏是我的代碼,傳遞一個變量使用.getJSON條件SQL查詢
<?php $cust_id = $_GET['cust_id']; ?>
<table class="display" id="invoice-disc-list" cellspacing="0" width="100%">
<thead>
<tr>
<th>INVOICE #</th>
<th>INVOICE DATE</th>
<th>SALESMAN</th>
<th>INVOICE AMOUNT</th>
<th>DISCOUNT</th>
</tr>
</thead>
</table>
<script>
$.getJSON('pages/lj_menu/monitoring/process/price_history_data.php', function(response) {
var custid = '<?php echo $cust_id; ?>';
// Initialize DataTables
$('#invoice-disc-list').DataTable({
iDisplayLength : 15,
processing: true,
data: response,
columns: [
{data: "INVOICE_NO"},
{data: "INVOICE_DATE"},
{data: "INVOICE_SALESMAN"},
{data: "INVOICE_AMOUNT"},
{data: "INVOICE_DISCOUNT"}
]
});
// Initialize AJAX onClick Data Send
window.someGlobalOrWhatever = response.balance;
});
</script>
如何發佈var custid = '<?php echo $cust_id; ?>';
到price_history_data.php
,使表裏面的數據只顯示了基於custid
變量,我將數據發送包含查詢..?再次
感謝您的幫助
通GET參數** **客戶ID作爲GET參數 –
你是什麼意思 ?以及如何做到這一點? –
像這樣'$ .getJSON(「pages/lj_menu/monitoring/process/price_history_data.php?custid = <?php echo $ cust_id;?>」,function(response)' –