My problem is that my JS function only works for me the first time I run it and if I try to execute it a second time it gives me this error:
<script type="text/javascript">
$(document).ready(function(){
$('#btnActualizar').click(function(){
actualizarHabitacion();
});
});
</script>
function actualizarHabitacion(){
id=$('#txtIdUp').val();
tip=$('#editTipo').val();
capadu=$('#editCapAdu').val();
capnin=$('#editCapNin').val();
capmax=$('#editCapMax').val();
valadu=$('#editValAdu').val();
valnin=$('#editValNin').val();
des=$('#editDescripcion').val();
actualizarHabitacion = "";
$.ajax({
type:"POST",
url:"../php/updates.php",
data: {id,tip,capadu,capnin,capmax,valadu,valnin,des,actualizarHabitacion},
success:function(r){
if(r==1){
$('#tabla').load('componentes/tabla_habitaciones.php');
alertify.success("Habitacion Actualizada con exito");
}else{
alertify.error("Fallo el servido");
}
}
});
}
The only way to re-execute it is to reload the page, which I do not want. It would be appreciated if you could give me some advice:)