0
Fala galera, I have a question here.. I want to be able to delete a row from the table with Ajax just by clicking on a button without having to load the screen.. I already searched and tried to do more did not work.. I have the following html code:
<tr>
<td><?= $client['name']; ?></td>
<td><?= $client['email']; ?></td>
<td><?= $client['tell']; ?></
<td class="text-center"><button id="delete" class="glyphicon glyphicon-remove"></button></td>
</tr>
and java script:
$("#delete").click(function(){
var id = $(this).attr("id");
var request = $.ajax({
type: "POST",
data: "id="+id,
url: "/removeClient",
dataType: "json"
});
return false;
});
the php part I solve.. I just want to receive a $_POST['id'] and move on to the method that will delete the record. I thank you!
Dude I did like your code but it didn’t work, and it doesn’t return anything in the console nor the ('error in php').. I tried to change some things but nothing.. x=
– wDrik
I tested and the code is just that, you’re doing something wrong, you’re probably missing something in the table, or the path to php is not correct.
– Gabriel Mourão