title: how to run an $.ajax method on dialog ok button click
body: <p>I want to delete a row from my html table on the click of corresponding delete button. What happens is that if i use a confirm box then everything goes fine but i dont want to use confirm box instead of that i want to use a dialog box with ok button and on the click of ok button it should perform the same function as it does with the confirm box. I am providing both the codes one with the confirm box and other with the dialog box .Help me do the same with that dialog box.
  jquery code of confirm box which works fine-</p>
  
  <pre><code>$(document).ready(function()
  {
      $('input[type=button]').click(function()
      {
          if (confirm("Are you sure you want to delete this row?"))
          {
              var ID = $(this).parent().parent().attr('id');
              var data = 'id=' + ID ;
              var parent = $(this).parent().parent();
  
              $.ajax(
              {
                     type: "POST",
                     url: "delete.php",
                     data: data,
                     cache: false,
  
                     success: function()
                     {
                      parent.fadeOut('slow', function() {$(this).remove();});
                     }
               });
          }
      });
  
  
  });
  </code></pre>
  
  <p>jquery code with dialog box -</p>
  
  <pre><code>$(document).ready(function(){
  $('#modal').dialog({
      autoOpen: false,
       title: 'Delete Confirm Box',
       width: 400,
        buttons : [
              {
                  text: 'OK',
                  click: function () {
                      $("#modal").dialog('close');
                         del_row();
                         alert("done");        
                  }
              },
              {
                  text: 'Cancel',
                  click: function () {
                      $("#modal").dialog('close');
                  }
              }
          ]
  });
  $('input[type=button]').click(function(){
     $('#modal').dialog('open');
      });
   });
  and the part which  i want to execute on ok click of dialog box-
  $('input[type=button]').click(function()
  {
      if (confirm("Are you sure you want to delete this row?"))
      {
          var ID = $(this).parent().parent().attr('id');
          var data = 'id=' + ID ;
          var parent = $(this).parent().parent();
  
          $.ajax(
          {
                 type: "POST",
                 url: "delete.php",
                 data: data,
                 cache: false,
  
                 success: function()
                 {
                  parent.fadeOut('slow', function() {$(this).remove();});
                 }
           });
      }
  });
  </code></pre>