【问题标题】:Fill DIV container with HTML table specified in other PHP file用其他 PHP 文件中指定的 HTML 表填充 DIV 容器
【发布时间】:2012-08-29 07:25:49
【问题描述】:

我需要如何更改loadPopupManual() 才能用content.php 中的内容填充DIV #popup_manual?特别是,我需要将content.php中指定的表插入#popup_manual。此表必须具有content.php 中的脚本定义的所有功能(一些按钮)。

test.php

$(document).ready(function() {
    loadPopupManual();
});

function loadPopupManual() {    // to load the PopupManual DIV
    $('#popup_manual').fadeIn("slow");  
}

<div id="popup_manual">
    // I need to fill this DIV with what I have in 'content.php'
</div>

content.php

<?php
    include_once 'include/connect_db.php';

    $query="SELECT * FROM aircrafts;";
    $result=execute_query($query);

?>

<script type="text/javascript" charset="utf-8">
         $(document).ready(function(){
             //...
         }
</script>

<table>
<tr>
//... some content is inserted here from DB ($result)
</tr>
</table>

【问题讨论】:

    标签: php jquery html-table


    【解决方案1】:

    你只需要使用$.get

    $.get('content.php', function(data) {
        $('#popup_manual').html(data);
    });
    

    所以它会变成:

    $(document).ready(function() {
        loadPopupManual();
    });
    
    function loadPopupManual() {    // to load the PopupManual DIV
        $('#popup_manual').fadeIn("slow"); 
        $.get('content.php', function(data) {
            $('#popup_manual').html(data);
        });
    }
    

    【讨论】:

    • 会保存content.php中定义的所有脚本吗?还是只会显示填满数据库数据的表格?
    猜你喜欢
    • 2017-10-07
    • 2014-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多