[英]How to load a html page in a jquery dialogbox.?
我创建了一个对话框,我想将HTML页面加载到其中
Assuming your dialog box is #dialog ( <div id="dialog"></div>
), this would work: 假设您的对话框是#dialog( <div id="dialog"></div>
),那么它将起作用:
$.get("url/to/yourpage.html", function(data) {
$("#dialog").html( data );
});
Something like this : 像这样的东西:
var url = "the url";
var dialog = $("#dialog");
if ($("#dialog").length === 0) { // only create if it doesn't exist
dialog = $('<div id="dialog"></div>').appendTo('body');
}
// load remote content
dialog.load(
url, {}, function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
// your options
})
})
Since you said you've already created the dialog, loading and opening then become as simple as: 正如您说的那样,您已经创建了对话框,因此加载和打开就变得非常简单:
$('#dialog').load( url, function(){
$(this).dialog('open');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.