I got an identical error to the one you're getting now. I once encountered a very similar error using the Chosen library. The problem was (in Chosen's case) that IDs with the []
characters were being used, thus confusing Javascript between css selectors and ids (remember that in CSS we can use []
to specify attributes).
In the case of DataTables, however, I noticed that the DataTables script itself was prepending class = " "
before the first element in every tr element within the tbody
.
The reason for this was because the HTML output from the php had a logical error. The faulting code:
<?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
}
?>
There was an error at the bottom of the long, long table, indicating that postgres could not jump to row 208. This told me I needed to stop looping at i - 1
, or $currentRow - 1
.
Hence the fixed, working code:
<?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
}
?>
Performing this change allowed DataTables to perform properly.
So although I cannot provide a working solution, I do advise you to look at your html mark-up, as that may be the source of your problem (ex, does your table have a tbody
?).
else if
that you mention.