带有HTML内容的JQuery对话框

时间:2013-12-13 06:21:19

标签: php jquery dialog

我遇到了对话框问题。我想在对话框中显示另一个页面的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
            });
        }
    })

applicant.html

some html codes

我想将applicant.html的html内容放入index.php

的对话框中

1 个答案:

答案 0 :(得分:2)

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

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

请注意,这仅在URL位于同一域中时才有效;跨域AJAX阻止将其用于其他域。如果你需要,你将不得不使用IFRAME;请参阅How do you open a URL in a dialog box JQUERY UI

中的答案
相关问题