php - Delete row from Table with ajax -


i found code on internet , need ajax code post $row[id] delete.php file:

echo "<td><a id=$row[id]  onclick=\"if(confirm('are sure want delete this?')) deleterow(this.parentnode.parentnode.rowindex); return false; \" href=\"\"  >del</a> </td>" 

i have tried:

function deleterow(i){     var makarios = document.getelementbyid('m').deleterow(i)     var mak;      if (window.xmlhttprequest) {         // mozilla, safari, ...          mak = new xmlhttprequest();     } else if (window.activexobject) {         // ie 8 , older         mak = new activexobject("microsoft.xmlhttp");     }      var data = "id=" + makarios;     mak.open("post", "delete_basket.php", true);     mak.setrequestheader("content-type", "application/x-www-form-urlencoded");     mak.send(data); } 

in case want jquery example looks lot easier jazz in comment:

function deleterow(id) {   $.ajax({     type: "post",     url: "delete.php",     data: { id: id },     success: function(data){       alert("deleted");     }   }); } 

this makes assumption delete script looking $_post['id']

you need include jquery library. can use hosted 1 if want: here's resource linking hosted versions: is there link "latest" jquery library on google apis?

i go 1.8 or now. using latest can lead undesired side effects when major changes happen.

if have specific question feel free ask , may update.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -