我遇到了与您现在遇到的相同的错误。我曾经在使用 Chosen 库时遇到过类似的错误。问题是(在选择的情况下)使用了带有[]
字符的 ID,从而混淆了 css 选择器和 id 之间的 Javascript(请记住,在 CSS 中我们可以[]
用来指定属性)。
然而,在 DataTables 的情况下,我注意到 DataTables 脚本本身class = " "
在tbody
.
这是因为 php 的 HTML 输出存在逻辑错误。故障代码:
<?php
for ($currentRow = 0 ; $currentRow <= $query_length; $currentRow++) {
?>
<tr>
<?php
list($job_id, $company_id, $job_title, $industry_id, $profession_int, $job_openings, $job_city, $job_salary_start, $job_end_date, $job_start_date, $job_skills, $company_name, $isConfidential, $job_experience_level) = dbRow($query_results, $currentRow);
echo "<td class = \"detailed-job-row\">" . $job_title . "</td>";
echo "<td class = \"detailed-job-row\">" . $company_name . "</td>";
echo "<td class = \"detailed-job-row\">" . $industry_id . "</td>";
echo "<td class = \"detailed-job-row\">" . $profession_int . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_openings . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_city . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_salary_start . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_end_date . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_start_date . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_skills . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_experience_level . "</td>";
?>
</tr>
<?php
} ?>
</tbody>
</table>
<?php
}
?>
long, long 表的底部有一个错误,表明 postgres 无法跳转到第 208 行。这告诉我我需要在i - 1
, 或处停止循环$currentRow - 1
。
因此,固定的工作代码:
<?php
for ($currentRow = 0 ; $currentRow <= $query_length - 1; $currentRow++) {
?>
<tr>
<?php
list($job_id, $company_id, $job_title, $industry_id, $profession_int, $job_openings, $job_city, $job_salary_start, $job_end_date, $job_start_date, $job_skills, $company_name, $isConfidential, $job_experience_level) = dbRow($query_results, $currentRow);
echo "<td class = \"detailed-job-row\">" . $job_title . "</td>";
echo "<td class = \"detailed-job-row\">" . $company_name . "</td>";
echo "<td class = \"detailed-job-row\">" . $industry_id . "</td>";
echo "<td class = \"detailed-job-row\">" . $profession_int . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_openings . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_city . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_salary_start . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_end_date . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_start_date . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_skills . "</td>";
echo "<td class = \"detailed-job-row\">" . $job_experience_level . "</td>";
?>
</tr>
<?php
} ?>
</tbody>
</table>
<?php
}
?>
执行此更改允许 DataTables 正确执行。
因此,尽管我无法提供可行的解决方案,但我建议您查看您的 html 标记,因为这可能是您的问题的根源(例如,您的表格是否有tbody
?)。