簡體   English   中英

打印到彈出窗口,而不是在主窗口上

[英]Printing into a pop-up, instead on main window

我有此功能,可顯示“ Articles”數據庫中的所有文章標題。

function show()
{
    database();

    $sql = "SELECT title FROM `Articles`";

    $titleSql = mysql_query( $sql ) or die("Could not select articles:");

    $html = '<html><body><div class="container"><h2>Basic List Group</h2><ul class="list-group">';

    while ($title = mysql_fetch_array($titleSql)) {
        $html .= '<li class="list-group-item">'.$title["title"].'</li>';
    }

    $html .= '</ul></div></body></html>';

    echo $html;
//  die("Functie terminata cu succes! :)");
 //   die(json_encode(array("mesaj" => "Entered data successfully ")));

}

這是javascript中的函數。

function show()
    {
        var n = $('#show').val()
        $.post("functions.php", {show:n}).done(function(mesaj){
            alert(mesaj);
        });
    }

問題:由於有alert(mesaj),它會在彈出窗口中顯示字符串$ html,而不是我希望的那樣在我的主窗口中! 如何修改我的功能,以便文章列表顯示在m窗口上?

您必須提供一個將其設置數據的容器ID。 波紋管我把它放在文檔中。

function show()
    {
        var n = $('#show').val()
        $.post("functions.php", {show:n}).done(function(mesaj){
            $(document).html(mesaj);
        });
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM