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

Printing into a pop-up, instead on main window

本文关键字:窗口 打印      更新时间:2023-09-26

我有这个函数从' 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);
        });
    }

问题:由于警告(mesaj),它显示字符串$html到弹出窗口,而不是在我的主窗口,因为我希望!我如何修改我的功能,使文章列表将显示在我的窗口?

你必须给一个容器id,它将设置数据。下面我把它放到文档中。

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