【发布时间】:2014-09-16 13:36:28
【问题描述】:
我正在努力解决这个问题:
- 我有一个使用 jquery 表排序器排序的 html 表。
- 当按下“搜索”按钮时,我使用 ajax 从 php-script 获取整个表。
- 按下“Searh”按钮时,我有搜索选项传递给 php 代码。
- 完成新搜索后,我删除了整个表格,并将新表格附加到文档中。
- 我在搜索和追加完成后调用 tablesorter。
- 我要排序的列中的一些数据只是:'-' 来标记未命名,而一些是公司名称。
问题:
- 当所有的搜索选项都是默认的,这意味着所有的行都被提取了,tablesorter 工作得很好。如果我给一个搜索选项,无论它是什么,tablesorter 都无法对某些列进行排序。
- 搜索选项仅影响将哪些行提取到表中,不影响其他任何内容。
- 奇怪的是,在我的本地测试 WAMP 服务器中,它每次都能正常工作,但在远程服务器中却是这样。
- 更奇怪的是,如果我选择多个搜索选项,它会再次起作用。
- “-”标记似乎对排序没有任何负面影响。
- 共有三列开始以这种方式运行,并且所有列都只有文本数据。
- 并非所有列都彼此相邻。
- 其他包含文本、数字等的列都可以正常工作。
获取表格的代码:
$.ajax({
url:"includes/getfromdb.php",
type: "POST",
data: $("#usersearchform").serialize(),
success:function(result){
$("#custresults").empty(); // container for the results
$("#custresults").append(result);
$("#customertable").tablesorter();
},
error: function(err) {
alert(err);
}
});
这在我的 WAMP 服务器上有效,而不是在代码的最终休息地远程服务器上,这可能意味着存在一些配置问题或类似问题..?或者你怎么看?
我不知道我现在可以提供哪些其他详细信息,因此如有必要,我会添加更多信息。
更新 17.9.14-08.16 更多细节。 php生成的表没有数据,只有结构:
<div id="custresults" class="results">
<table id="customertable" class="tablesorter">
<thead>
<tr class="nohower">
<th class="smalltd header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
<th class="header"></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
当然还有更多。 tr:s 和 td:s。那里的正常结构。 我已经尝试触发更新,但它对我不起作用。我认为这是因为整个表被删除然后再次创建,而不是仅仅更新它。
【问题讨论】:
标签: php jquery html ajax tablesorter