PHP reuseable delete row with ajax

My code repeat for everytable. The ajax function and file delete.php repeat everytime I want to delete. Example I have 100 table in mysql I have to make 100 delete.php
=> can I use 1 delete.php for all, same with ajax function as well

Thank you

PHP code,

echo"<td><a href='#' onclick='doConfirm(".$id.")'>Delete</a></td>";

Ajax code

function doConfirm(id)

        var xhttp; 

        var ok = confirm("Are you sure to Delete?")
        if (ok)

          xhttp= new XMLHttpRequest();
           xhttp.onreadystatechange = function() {
            if (xhttp.readyState == 4 && xhttp.status == 200) {


"GET", "delete.php?id=" + id,true);





Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.