This worked for me --
$("#dialog-confirm").html('Do you want to permanently delete this?');
$( "#dialog-confirm" ).dialog({
resizable: false,
title:'Confirm',
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
},
OK:function(){
$('#loading').show();
$.ajax({
type:'post',
url:'ajax.php',
cache:false,
data:{action:'do_something'},
async:true,
success:function(data){
var resp = JSON.parse(data);
$("#loading").hide();
$("#dialog-confirm").html(resp.msg);
$( "#dialog-confirm" ).dialog({
resizable: false,
title:'Confirm',
modal: true,
buttons: {
Close: function() {
$( this ).dialog( "close" );
}
}
});
}
});
}
}
});