假设您有以下标记
<div id="__DialogPanel" style="display:none" title=""></div>
使用此代码您可以设置对话框
$("#__DialogPanel").dialog({
autoOpen: false,
resizable: false,
position: 'center',
stack: true,
height: 'auto',
width: 'auto',
modal: true
});
使用此代码,您可以显示对话框并包含 ajax 调用的结果
$.ajax({
type: "get",
dataType: "html",
url: 'some/url',
data: {},
success: function(response) {
$("#__DialogPanel").empty().html(response).dialog('open');
}
});
使用此代码,您可以在对话框中提交表单,然后如果一切正常则关闭它,或者如果有错误则再次显示表单
$.ajax({
type: 'post',
dataType: 'html',
url: '/someother/url',
async: false,
data: $("#myform").serialize(),
success: function (response, status, xml) {
//Check for error here
if (error) {
$("#myform").parent().html('').html(response);
}
else {
$("#__DialogPanel").dialog('close');
}
}
});
希望能帮助到你!