I assumed that what your difficulty is updating the HTML table, not the table in the database.
You can do something like this:
HTML:
<table>
<tr class='linha' data-id="1">
<td>Linha 1</td>
<td class='coluna'>Não</td>
</tr>
<tr class='linha' data-id="2">
<td>Linha 2</td>
<td class='coluna'>Não</td>
</tr>
<tr class='linha' data-id="3">
<td>Linha 3</td>
<td class='coluna'>Não</td>
</tr>
<tr class='linha' data-id="4">
<td>Linha 4</td>
<td class='coluna'>Não</td>
</tr>
</table>
The data-id
attribute contains id
for that row in the database.
Javascript / jQuery:
$(".linha").click(function() {
$(this)
.children(".coluna")
.html("Atualizado: " + $(this).data("id"));
});
The $(this).data("id")
function above returns the data-id
of that row. You will use this in your AJAX request.
The $(this).children(".coluna")
is to get the specific column for that row.
View this example in JSFiddle .
You can change this so everything happens to the column click or an image inside it if you want. (Use $(this).parents(".minha-classe")
to get a parent tag if needed).
Read here about Unobtrusive Javascript .