Update button data of a query without refresh on the page

Asked

Viewed 1,196 times

-3

I am creating an application in PHP (Codeigniter) and I came across the following situation. I have a table on my page that brings all the results of a query in the database. I want to create a button to update data but I did not want the same to refresh the page. I would like a help on how I can do this.

Thanks in advance.

  • 1

    I recommend you take a look at AngularJS

  • Why don’t you make a jQuery that brings the query to you? no refresh? Don’t even need the button, just specify how many seconds...

  • 1

    On the level of clarification: I denied the answer, because we already have many questions (and answers) about doing something without refresh

  • 1

    Related: http://answall.com/questions/43087/como-se-actualizr-form-form-sem-refresh?rq=1

  • Translation: You want to make a request through the AJAX.

1 answer

2

Uses Jquery to make an AJAX request.

When you click the refresh button you make a request on the server returning a json with your desired result in your case I believe that a list that populates your table.

Example :

$("#btnRefresh").click(function(){
      $.get(aquisuaurlqueretornajson)
         .done(function(response){
            $("#nomedatabela tbody tr").remove();//limpar os dados já populados
                for(var i in response){

                    var linhaTabela = $("<tr><td> " + response.algumatributodoseujson + "  </td>" + "</tr>");
                    $("#nomedatabela").append(linhaTabela);

                    }
    });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.