Tengo el siguiente código, el cual me muestra los registros de personas apartir de un query. Quiero mandar por medio de la funcion post el id_Persona por medio de un formulario oculto, y se mande a página idsPersonas.php cachando solo el id_Persona
Lo hice de esta manera el código para mandar llamar la función post
<tr class='clickable-row' onclick="post('/idsPersonas.php/',{ids: <?php "$lista[id_Persona];" ?>});">
Al momento de ver la pagina, me manda a una página undefined
.
¿Alguna sugerencia?
Este es mi código:
<table id="example" cellspacing="0" width="100%">
<thead class="text-primary">
<tr >
<th class="cabezera"><center><h4>Fecha</h4></center></th>
<th class="cabezera"><center><h4>Hora</h4></center></th>
<th class="cabezera"><center><h4>Nombre</h4></center></th>
</tr>
</thead>
<?php
if(count($listado)> 0 ){
foreach($listado as $lista)
{
$cuenta++;
?>
<tbody>
<tr class='clickable-row' onclick="post('/idsPersonas.php/',{ids: <?php "$lista[id_Persona];" ?>});">
<td><?php printf("%s",$lista["Fecha"]); ?></td>
<td><?php printf("%s",$lista["Hora"]); ?></td>
<td><?php printf("%s",$lista["Nombre"]); ?></td>
</tr>
<?php
}
}else {
?>
<h3> No hay </h3>
<?php
}//fin else
//printf($cuenta_eventos);
?>
</tbody>
</table>
Codigo JS:
function post(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
console.log(method);
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
}
document.body.appendChild(form);
form.submit();
}