我正在尝试在jquery对话框中加载html页面但它不起作用。下面是我的jquery代码。 " openTerms"链接中有单击时触发功能。它会打开对话框,但会给我资源找不到错误。然而" terms.html"驻留在项目中并添加为项目。
<a id="someclientid" name="someuniqueid" href="javascript:void(0);" onclick="openTerms();">Terms and Conditions</a>
<script>
function openTerms()
{
pathArray = location.href.split( '/' );
protocol = pathArray[0];
host = pathArray[2];
url = pathArray[0] + '//' + pathArray[1] + '//' + pathArray[2] + '//' + pathArray[3]
url = url + "/Orchard.Club" + "/terms.html";
var page = url;
alert(url);
var $dialog = $('<div></div>')
.html('<iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"></iframe>')
.dialog({
autoOpen: false,
modal: true,
height: 700,
width: 1100,
title: "Terms and Conditions",
buttons: {
Cancel: function () {
$(this).dialog("close");
}
},
close: function () { setFormControls(); },
open: function () {
}
});
$dialog.dialog('open');
}
</script>
}
答案 0 :(得分:1)
加载内容后,您需要显示对话框
$.get(url, function (data) {
$("#dialog").html(data).dialog('open');
});
另外尝试load()方法加载内容,如
$("#dialog").load(url, function(){
$(this).dialog('open');
});