Guest User

Untitled

a guest
Jan 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <script>
  2. $(document).ready(function() {
  3. /* load table with page load*/
  4. $("#sort tbody").load("inc/index_table.php");
  5.  
  6. /* row deletion */
  7. $(".deletelink").click(function(){
  8. var id = $(this).attr("id");
  9. $.ajax({
  10. beforeSend: function (request) {
  11. var answer = confirm("Are you SURE you want to delete this?/nThis action is NOT reversible.")
  12. if (answer){ return(true); }
  13. else { return(false); }
  14. },
  15. type: "POST",
  16. url: location.href,
  17. data: "delete="+id,
  18. error: function() {
  19. console.log("Theres an error with AJAX deletion");
  20. },
  21. success: function(){ //a.td.tr.remove just that row rather than the whole table
  22. $this.parent().parent().remove();
  23. console.log("Deleted.");
  24. }
  25. });
  26. });
  27.  
  28. });
  29. </script>
  30.  
  31. $("#sort tbody").load("inc/index_table.php");
  32.  
  33. /* row deletion */
  34. $("#sort tbody").on("click", ".deletelink", function(){
  35. //...rest of code the same
  36. });
  37.  
  38. $("#sort tbody").load("inc/index_table.php");
  39.  
  40. $("#sort tbody").delegate(".deletelink", "click", function(){
  41. //...rest of code the same
  42. });
  43.  
  44. $("#sort tbody").load("inc/index_table.php", function(){
  45. /* row deletion */
  46. $(".deletelink").click(function(){
  47. // .. your code as before.
  48. });
  49. });
  50.  
  51. $("#sort tbody").load("inc/index_table.php", function() {
  52.  
  53. /* row deletion */
  54. $(".deletelink").click(function(){ ....
  55. });
  56. });
  57.  
  58. $(".deletelink").on('click',function(e){
  59.  
  60. e.preventDefault();
  61.  
  62. $(".deletelink").live('click',function(){
  63. // ajax call handling code here
  64. });
Add Comment
Please, Sign In to add comment