I invoke the on-the-fly dialog box (on click) without first setting it as var. For instance:
$(".deleteSaved").click(function() { save_id = $(this).attr('id'); div="<div>Are you sure you want to delete this?</div>"; $(div).dialog({ buttons: { "Delete": function() { $.ajax ({ url:"util.php", data:"q=0&f=delete&save_id="+save_id, success: function(result){ $(this).dialog("close");
But when I call $(this).dialog("close");
in ajax success function, I get the following error:
Uncaught cannot call methods on dialog prior to initialization; attempted to call method 'close'
Inside the button cancel
$(this).dialog("close");
works just fine.
How can I make the close function work as a result of a successful ajax call?
source share