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
- $(".delete").click(function() {
- if (confirm("Are you sure you wish to delete this member?")) {
- var id = $(this).attr("id");
- var dataString = 'id='+ id ;
- var parent = $(this).parent().parent();
- $.ajax({
- type: "POST",
- url: "../includes/forms/delete_member.inc.php",
- data: dataString,
- cache: false,
- success: function()
- {
- if(id % 2)
- {
- parent.fadeOut('slow', function() {$(this).remove();});
- }
- else
- {
- parent.slideUp('slow', function() {$(this).remove();});
- }
- }
- });
- return false;
- }
- });