问题描述:

i need some explanation for this, for what this line is doing and how to use for updating/deleting data in database with use of Ajax. thanks

function deletedata(str){

var id = str;

$.ajax({

type: "GET",

url: "url.php?id="+id

}).done(function( data ) {

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

search();

});

}

网友答案:

it calls a php page in the same directory called

url.php

url.php takes 1 Argument - which is the 'id'.

It must have inside it something like

<?php echo mysql_query("delete from TABLENAME where id == $_GET['id']");?>

Keep in mind to use 'htmlspecialchar' on the ID to not get sql-injected.

相关阅读:
Top