Guest User

Guest User

  • Tech Writer
  • 611
  • 116.7k

Set sweet alert in jquery.

Sep 2 2020 6:41 AM
I have use this code for delete record with sweet aleart .It's not working with sweet aleart and without sweet aleart it's working .please help me.
  1. $(document).ready(function () {  
  2. $("#Report").on('click''.btndelete'function () {  
  3. swal({  
  4. title: "Confirmation?",  
  5. text: "Are you sure you want to delete record?",  
  6. type: "warning",  
  7. confirmButtonClass: "btn-danger",  
  8. showCancelButton: true,  
  9. confirmButtonText: "Yes,Please Delete it!",  
  10. closeOnConfirm: false  
  11. }, function () {  
  12. swal("Deleted!""Data has been successfully deleted.""success");  
  13. });  
  14. var ab = $(this).closest('#item');  
  15. ab.remove();  
  16. var id = $(this).attr('id');  
  17. $.ajax({  
  18. url: "DeleteReport",  
  19. type: "POST",  
  20. data: { "ContactUsId": id },  
  21. success: function (data) {  
  22. if (data.status == true) {  
  23. $(this).closest('#item').remove();  
  24. }  
  25. else {  
  26. alert("Something went wrong");  
  27. return false;  
  28. }  
  29. },  
  30. error: function (er) {  
  31. alert(er);  
  32. return false;  
  33. }  
  34. });  
  35. });  
  36. });  

Answers (6)