Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. function removeTr(id, callback){
  2.  
  3. $.ajax({
  4. url: '/projetophp/controllers/controller-cliente.php',
  5. dataType: 'json',
  6. type: 'GET',
  7. data: {
  8. requisicao: "excluirClientes",
  9. id:id
  10. },
  11.  
  12. success: function(){
  13. callback();
  14. }
  15.  
  16. });
  17. };
  18.  
  19. $(document).ready(function(){
  20.  
  21. /*Função para pegar os registros no banco de inserir na página*/
  22. $.ajax({
  23. url: '/projetophp/controllers/controller-cliente.php',
  24. dataType: 'json',
  25. type: 'GET',
  26. data: {
  27. requisicao: "listarClientes"
  28. },
  29. success: function(result) {
  30. if(result){
  31. var $cliente = $("#tabela tbody"),
  32. options = "" ;
  33. $.each(result, function( index, value ) {
  34. options += ("<tr><td>" + value.id + "</td><td>" + value.cliente + "</td><td>" + value.email + "</td><td>"+ value.dominio +"</td><td>" + value.rds +"</td><td>"+ value.stack +"</td><td><button type='button' class='btn-editar btn btn-primary'>Editar</button><button type='button' value='delete' data-id='"+ value.id +"' class='btn-excluir btn btn-danger' data-toggle='modal'>Excluir</button></td></tr>");
  35. });
  36. $cliente.append(options);
  37.  
  38. /*Função para remover tr*/
  39. $('.btn-excluir').on('click', function(){
  40. event.preventDefault();
  41. var $this = $(this);
  42. removeTr($this.data('id'), function(){
  43. $this.closest('#tabela tr').remove();
  44.  
  45.  
  46. });
  47. });
  48. }
  49. }
  50.  
  51. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement