带有HTML内容的JQuery对话框


JQuery Dialog Box with HTML Contents

我的对话框有问题。我想在对话框中显示另一个页面的HTML内容。例如

index.php

 var url = "/leave_ot/statistics.php?what="+type+"&item="+applicant;
   //alert(url);
    $.ajax({
        type    : 'GET',
        url     : url,
        success : function(result)
        {
            $( "#dialog" ).dialog({
                height: 140,
                modal: true
            });
        }
    })

application.html

some html codes

我想把application.html的html内容放入index.php 的对话框

使用.html()方法将HTML结果插入div.

$.ajax({
    type    : 'GET',
    url     : url,
    success : function(result)
    {
        $( "#dialog" ).dialog({
            height: 140,
            modal: true
        }).html(result);
    }
});

请注意,只有当URL位于同一域中时,这才有效;跨域AJAX防止将其用于其他域。如果你需要,你必须使用IFRAME;请参阅如何在对话框中打开URL JQUERY UI

中的答案