Guest User

Untitled

a guest
Feb 17th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. include "config.php";
  3.  
  4. $id = $_REQUEST['id'];
  5.  
  6. // Delete record
  7. $query = "DELETE FROM mi_home_tv WHERE id='$id'";
  8. mysqli_query($link,$query);
  9.  
  10. echo 1;
  11.  
  12. jquery+ajax
  13. <script src='jquery-3.0.0.js' type='text/javascript'></script>
  14. <script type="text/javascript">
  15. $(document).ready(function(){
  16.  
  17. // Delete
  18. $('.delete').click(function(){
  19. var el = this;
  20. var id = this.id;
  21. var splitid = id.split("_");
  22.  
  23. // Delete id
  24. var deleteid = splitid[1];
  25.  
  26. // AJAX Request
  27. $.ajax({
  28. url: 'remove.php',
  29. type: 'POST',
  30. data: { id:deleteid },
  31. success: function(response){
  32.  
  33. // Removing row from HTML Table
  34. $(el).closest('tr').css('background','tomato');
  35. $(el).closest('tr').fadeOut(800, function(){
  36. $(this).remove();
  37. });
  38. }
  39. });
  40. });
  41. });
  42. </script>
  43.  
  44. echo "<td> <span id='del_<?php echo $id; ?>' type='submit' class=' delete btn c-theme-btn c-btn-uppercase btn-xs c-btn-square c-font-sm'>Delete</span> </td>";
Add Comment
Please, Sign In to add comment