Reputation: 2560
I have a function that inside makes an ajax call. At first I open the dialog with the message 'Loading' inside. Can i access the dialog again after the call and close it ?. Below is my code:
function CallAction(){
$("#example").dialog({modal: true});
//do some ajax call
//how to close it after call ends ?
Thanks in advance
Upvotes: 0
Views: 798
Reputation: 1755
if you want to close the dialog in any case(success or error), use complete:
complete: function() {
$("#example").dialog({modal: true});
}
Upvotes: 0
Reputation: 388316
Use the complete callback of the ajax request, then use the close method to close the dialog
$.ajax({....}).always(function(){
$("#example").dialog('close');
})
Upvotes: 1
Reputation: 104775
Yes, close it in the AJAX success
or done
call:
success: function(data) {
//do stuff
$("#example").dialog('close');
}
Upvotes: 3