我需要帮助jQuery插件DataTables服务器端处理和过滤。过滤DataTables服务器端处理
我只是不知道如何获取显示的数据仅限于特定的post_id。
当前有请求查看数据时,用户链接到诸如www.example-site.com/post?id=123之类的东西,目标是让DataTables仅显示id = 123的数据。
我只能设置它只是从一个特定的表中拉出一切 - 我不知道如何告诉datatables只使用过滤器的id。
下面是HTML:
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function() {
$('#research').DataTable({
"processing": true,
"serverSide": true,
"ajax": "server_processing.php"
});
});
</script>
</head>
<body>
<table id="research" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Title</th>
<th>Link</th>
<th>Description</th>
<th>Type</th>
<th>Posted</th>
</tr>
</thead>
</table>
这里是SQL:
<?php
$table = 'example_table';
$primaryKey = 'id';
$columns = array(
array('db' => 'title', 'dt' => 0),
array('db' => 'link', 'dt' => 1),
array('db' => 'description', 'dt' => 2),
array('db' => 'category', 'dt' => 3),
array(
'db' => 'post_date',
'dt' => 4,
'formatter' => function($d, $row) {
return date('M d, Y', strtotime($d));
}
)
);
$sql_details = array(
'user' => '*USER*',
'pass' => '*PW*',
'db' => 'example_database',
'host' => 'localhost'
);
require('ssp.class.php');
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
);
?>
我不是通过贸易程序员,但我通常能搞清楚该怎么做了约搜索线上。我在这个完全损失...任何帮助将不胜感激。
我已经完成了以下内容:(1)检索与'purl.js id'查询字符串变量; (2)设置'ajax'选项来接收变量:''server_processing.php?id =“+ id';(3)设置** server_processing.php **来过滤查询字符串变量。我知道我确实正在检索'id'查询字符串,并且** server_processing.php **可以过滤查询字符串。我不知道的是,我是否正确地将'id'变量传递给了ajax选项,以及ajax是否正确发送了查询字符串。有没有办法可以检查ajax是否发送查询? – bafox
....我注意到我的脚本拦截器(ublock)已打开。它阻止了这个请求。你的解决方案工作 - 谢谢你。 – bafox