code_junkie

AJAX delete - using jQuery

Nov 13th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. $("img.delete").click(function() {
  2. var id = $('#id').attr('value');
  3. $.ajax({
  4. type: "POST",
  5. url: "delete.php",
  6. data: "id="+ id,
  7. success: function(){
  8. $('tr.selector').remove();
  9. $('div.success').fadeIn();
  10. }
  11. });
  12. return false;
  13. });
  14.  
  15. $("img.delete").click(function() {
  16. var row = $(this).parents('tr:first');
  17.  
  18. ...
  19.  
  20. success: function(){
  21. $(row).remove(); //Remove the row containing the image element
  22. ...
  23. }
  24.  
  25. ...
  26. });
  27.  
  28. $("img.delete").click(function(){
  29. var row = $(this).parents('tr:first');
  30. $.ajax({
  31. type: "POST",
  32. url: "delete.php",
  33. data: "id="+ id,
  34. success: function(){
  35. $(row).remove(); //Remove the row containing the image element
  36. }
  37. });
  38.  
  39.  
  40. return false;
  41. });
  42.  
  43. var id = $(row).attr('id');
Add Comment
Please, Sign In to add comment