Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeTr(id, callback){
- $.ajax({
- url: '/projetophp/controllers/controller-cliente.php',
- dataType: 'json',
- type: 'GET',
- data: {
- requisicao: "excluirClientes",
- id:id
- },
- success: function(){
- callback();
- }
- });
- };
- $(document).ready(function(){
- /*Função para pegar os registros no banco de inserir na página*/
- $.ajax({
- url: '/projetophp/controllers/controller-cliente.php',
- dataType: 'json',
- type: 'GET',
- data: {
- requisicao: "listarClientes"
- },
- success: function(result) {
- if(result){
- var $cliente = $("#tabela tbody"),
- options = "" ;
- $.each(result, function( index, value ) {
- 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>");
- });
- $cliente.append(options);
- /*Função para remover tr*/
- $('.btn-excluir').on('click', function(){
- event.preventDefault();
- var $this = $(this);
- removeTr($this.data('id'), function(){
- $this.closest('#tabela tr').remove();
- });
- });
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement