jQuery confirmation dialog, function on confirmation

jQuery confirmation dialog, function on confirmation

Hi everyone,

  I am writing a script runs an Ajax function upon confirmation - in this case deleting an entry from a MySQL database table.

I have used the jQuery UI dialog widget in the past but have only redirected to other pages with button clicks. In this case, when the user clicks on "Okay," I want to run the Ajax command.

I tried simply inserting the Ajax after 'Okay'; function() { } but this did not work. I had to settle on using confirm() instead, which works but throws off the jQuery UI themed page

Here is the Ajax I am trying to run. To complicate matters even more, when the record is deleted, the entire table row that contained it is removed as well - this is working fine using confirm(), but I seem to recall glitches when trying to use the dialog

  1. $(".delete").click(function() {
  2. if (confirm("Are you sure you wish to delete this member?")) {
  3. var id = $(this).attr("id");
  4. var dataString = 'id='+ id ;
  5. var parent = $(this).parent().parent();

  6. $.ajax({
  7. type: "POST",
  8. url: "../includes/forms/delete_member.inc.php",
  9. data: dataString,
  10. cache: false,

  11. success: function()
  12. {
  13. if(id % 2)
  14. {
  15. parent.fadeOut('slow', function() {$(this).remove();});
  16. }
  17. else
  18. {
  19. parent.slideUp('slow', function() {$(this).remove();});
  20. }
  21. }
  22. });

  23. return false;
  24. }
  25. });