I'm wanting to order, but when I click on the headers, this happens.
When I do it with a table created in hard (hard data) it works perfectly, also when the data is already loaded from the beginning with PHP, but when I fill the table from the comboBox, that happens.
HTML
<table class="datos" id="myTable">
<thead>
<tr>
th con los cabezales
</tr>
</thead>
<tbody id="tabla">
</tbody>
</table>
PHP to fill table (in this same way I fill the table without needing the comboBox and it works)
<?php
require_once 'conexion.php';
if (isset($_POST["selected"])){
$ubigeo = $_POST["selected"];
$consulta = Query;
$queryResult = $pdo->query($consulta);
$html = "";
$string = '.';
while ($row = $queryResult->fetch(PDO::FETCH_ASSOC))
{
$html .=
'<tr class="fila">'.
'<td>'.
td con las filas
'</tr>';
}
echo $html;
}else{
}
?>
JS to fill the table with the comboBox
$(document).ready(function(){
$("#provincia").on('change', function () {
$("#provincia option:selected").each(function () {
elegido="9";
$.post("datos/tablaCandidatos.php", { elegido: elegido }, function(data){
$("#tabla").html(data);
});
});
});
});