First, this example is modified based on the edited version of the guestbook. We used jquery.js to implement ajax and dom deletionFirst add Copy the code The code is as follows: <br></p> <br>Add a <br><p><span><u>copy code to the table</u></span> The code is as follows:</p> <p><br>id="t<!--{$item.id}-->" <br></p> <br>Write js:<br><p><span><u>Copy code</u></span> The code is as follows:</p> <p><br><script> <br>function delItem (id) { <br>$.get('delete.php?id='+id,null,function (msg) {//ajax request, execute the following code after the request<br>if ('1'==msg) {//Return 1 to indicate success<br>$('#t'+id).remove();//Change the id to txx Table delete <br>} else {//Otherwise an error message will pop up <br>alert(msg); <br>} <br>}); <br>} <br> Change the delete link to delete.php by changing the error statement Just output it directly. OK done. index.tpl:Copy the code The code is as follows: All comments Welcome: Exit Login Register Leave a message [] Posted by: Attachment: < ;!--{/if}--> Modify Delete <br>function delItem (id) { <br>$.get('delete.php?id='+id,null,function (msg) { <br>if ('1'==msg) { <br>$('#t'+id).remove(); <br>} else { <br>alert(msg); <br>} <br>}); <br>} <br>< ;/script> <br></body> <br></html> <br></p> <br>delete.php :<br><p><span><u>Copy code</u></span> The code is as follows:</p> <p><br><?php <BR>require('common.php') ; <BR>// Query message information <BR>$q = $query->query('select * from gb_content whereid'])); <br>$rs = $query->fetch_array($q); <br>$error = array (); <br>if ($rs['user_id']!=intval($_SESSION['user_id'])) {// Determine whether the user_id is the same<br>$error = 'You cannot delete this information, you can only delete the information you posted. '; <br>} <br>if (!$error) { <br>$query->query('delete from gb_content whereid']));//Delete statement <br>if ($rs['user_file']) {//Delete attachment <br>@unlink('uploads/'.$rs['user_file']); <br>} <br>echo 1;//Indicates success <br>} else { <br>echo $error; <br>} <br>?> <br></p> <p> The above has introduced basement jaxx PHP+ajax to delete data without refreshing, including the content of basement jaxx. I hope it will be helpful to friends who are interested in PHP tutorials. </p> <p> </p>