I'm trying to make a PivotTable for editing the data without refresh, but by double-clicking the line nothing happens, it follows the JQuery code
$(document).ready(function(){
$('#tblEditavel tbody tr td.editavel').dblclick(function(){
if($('td > input').length > 0){
return;
}
var conteudoOriginal = $(this).text();
var novoElemento = $('', {type: 'text', value:conteudoOriginal});
$(this).html(novoElemento.bind('blur keydown', function(e){
var keyCode = e.which;
var conteudoNovo = $(this).val();
if(keyCode == 13 && conteudoNovo != '' && conteudoNovo != conteudoOriginal){
var objeto = $(this);
$.ajax({
type:"POST",
url:"alterar.php",
data:{
id:$(this).parents('tr').children().first().text(),
campo:$(this).parent().attr('title'),
valor:conteudoNovo
}
success:function(result){
objeto.parent().html(conteudoNovo);
$('body').append(result);
}
})
}
else if( keyCode == 27 || e.type == 'blur')
$(this).parent().html(conteudoOriginal);
}));
$(this).children().select();
}
})
})
Just below the html code
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><scripttype="text/javascript" src="atualiza.js"></script>
<style>
table{
border-collapse: collapse;
}
table, td, th{
border: 1px solid black;
padding: 5px;
}
</style>
</head>
<body>
<table id="tblEditavel">
<thead>
<tr>
<th>Id</th>
<th>Nome</th>
<th>Valor</th>
<th>Vencimento</th>
</tr>
</thead>
<tbody>
<tr>
<td>74</td>
<td title="Nome" class="editavel">Fatura 45 Jhovini</td>
<td title="valor" class="editavel">2.350,00</td>
<td title="vencimento" class="editavel">10/02/2017</td>
</tr>
<tr>
<td>75</td>
<td title="Nome" class="editavel">Fatura 45 Jhovini</td>
<td title="valor" class="editavel">2.350,00</td>
<td title="vencimento" class="editavel">10/03/2017</td>
</tr>
<tr>
<td>76</td>
<td title="Nome" class="editavel">Fatura 45 Jhovini</td>
<td title="valor" class="editavel">2.350,00</td>
<td title="vencimento" class="editavel">10/04/2017</td>
</tr>
<tr>
<td>77</td>
<td title="Nome" class="editavel">Fatura 45 Jhovini</td>
<td title="valor" class="editavel">2.350,00</td>
<td title="vencimento" class="editavel">10/05/2017</td>
</tr>
<tr>
<td>78</td>
<td title="Nome" class="editavel">Fatura 45 Jhovini</td>
<td title="valor" class="editavel">2.350,00</td>
<td title="vencimento" class="editavel">10/06/2017</td>
</tr>
</tbody>
</table>
</body>
The php only sends to the server, where I'm wrong, it was working before but after I inserted ajax nothing works and I did not know how to go back to the previous file.