javascript - How to refresh a table inside a div tag using ajax php -


i have ajax table click event gets database data according clicked name first table , display second table employee information. problem employee information data pile in second table, want refresh second table every name user clicked. way second table inside div tag. here ajax code:

function putthis(control){ var getid = control.innertext; var first = $("#from[name=from]").val(); var second = $("#to[name=to]").val(); $.ajax({     type:'post',     url: 'testtable.php',     data: {id: getid,from: first,to: second},     cache: false,     global: false,     success:function(data)     {     $("#result").append(data);     alert("success: " + getid + " " + first + " " + second);     } }); } 

if reading question (and correct me if not), want replace contents of element rather append data element.

this can accomplished code changing line :

$("#result").append(data); 

to :

$("#result").html(data); 

append put data @ end of element before closing tag, while html consume element data inserting.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -