jquery asynchronous dialog
Are the jquery
modal dialogs asynchronous?
$('.triage').click(function() {
$("#dialog-modal").dialog({
position: [175, 175],
draggable: false,
height: 140,
modal: true
});
});
$.ajax(
{
type: "POST",
data: [],
dataType: "json",
contentType: "application/json; charset=utf-8",
url: "ReferralAutoTriage.asmx/RunTriageReferrals",
success: function(response) {
$("#dialog-modal")开发者_如何转开发.dialog('close')
},
failure: function(response) {
}
});
});
If the dialog is synchronous I need to make it asynchronous, so I can process ajax call while displaying dialog and close after I am done with it. Thanks.
Use the beforeSend
/complete
events to display/hide your dialog.
$('.triage').click(function() {
$.ajax({
type: "POST",
data: [],
dataType: "json",
contentType: "application/json; charset=utf-8",
url: "ReferralAutoTriage.asmx/RunTriageReferrals",
beforeSend: function() {
$("#dialog-modal").dialog({
position: [175, 175],
draggable: false,
height: 140,
modal: true
});
},
success: function(response) {
// whatever
},
failure: function(response) {
// whatever
},
complete: function() {
$("#dialog-modal").dialog('close');
}
});
});
It think you mean "blocking," not "synchronous," in which case - no, jQuery modal dialogs are not blocking. Only browser-native alert()
, confirm()
, and prompt()
dialogs can do that.
You can absolutely process ajax calls which a modal dialog is open.
It sounds like you're trying to figure out why your code isn't working. How about an SSCCE via http://jsfiddle.net or http://jsbin.com?
精彩评论