1
I tried several ways (SEVERAL SAME) but did not succeed! Most return me one UNDEFINED
Follows the code:
PHP:
<?php
require_once('acessabanco.php');
$objDb = new db();
$link = $objDb->conecta_banco();
$sql = "SELECT p.sequencia codigo,
p.nome_completo nome,
c.data_nascimento data,
t.celular_1 celular
FROM pessoas p,
clientes c,
telefones t
WHERE p.sequencia = t.cod_pessoa
AND c.cod_pessoa = p.sequencia";
$exec = mysqli_query($link, $sql);
if ($exec){
while ($clientes = mysqli_fetch_array($exec)){
echo('<tr><td id="sequencia">' . $clientes['codigo'] . '</td>
<td>' . $clientes['nome'] . '</td>
<td>' . $clientes['data'] . '</td>
<td>' . $clientes['celular'] . '</td>
<td><button type="button" id="teste" class="btn btn-primary btn-sm">Small button</button></td>
<td><a type="button" onClick="teste()" class="btn btn-danger btn-sm">Small button</a></td></tr>');
}
}
?>
JQUERY:
$(document).ready(function () {
$('#content').css('display', 'none');
$.ajax({
url: 'php/lista_clientes.php',
type: 'post',
success: function (data) {
$("#carrega_pag").append(data);
}
});
function teste (){
$('table tr').each(function(){
var teste = $(this).closest('td').attr('id');
console.log(teste);
)};
HTML:
<table class="table table-hover">
<thead>
<tr>
<th>Código</th>
<th>Nome Completo</th>
<th>Data de Nascimento</th>
<th>Celular</th>
<th>Opções</th>
</tr>
</thead>
<tbody id ="carrega_pag">
</tbody>
</table>
Could someone help me? I am very grateful! Because I have been here for a long time... Thank you!!
I lie, now he shows me nothing!
– Joao Pedro
Darlei, thank you for answering! That way it does not show me anything, I had already tried to put the CLICK function, by the class or by the ID, but it does not display anything, nor an Alert.
– Joao Pedro
I had an error in jquery, I hadn’t noticed either, I edited the answer, test now
– Darlei Fernando Zillmer
Thank you for answering! I tried with this new code, what happens: The TD that we put fixed, displays correctly, however how I am mounting the TD in PHP and giving an append, maybe it does not recognize.. That is, your code worked on the TD we put fixed, but the ones I mount in PHP, does not display anything, the button is not recognized..
– Joao Pedro