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

时间:2022-04-11 07:18:00

I have this function which shows all my articles titles from 'Articles' database.

我有这个功能,显示我的所有文章标题来自'文章'数据库。

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 ")));

}

This is the function in javascript.

这是javascript中的功能。

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

PROBLEM: because of the alert(mesaj), it shows the string $html into a pop-up, not on my main window, as I wish! HOW can I modify my functions so the articles list will show on m window?

问题:由于警报(mesaj),它将字符串$ html显示在弹出窗口中,而不是在我的主窗口上,如我所愿!我如何修改我的功能,以便文章列表显示在m窗口上?

1 个解决方案

#1


4  

you have to give a container id to which it will set the data. Bellow i put it in document.

你必须给一个容器ID,它将设置数据。贝娄我把它放在文件中。

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

#1


4  

you have to give a container id to which it will set the data. Bellow i put it in document.

你必须给一个容器ID,它将设置数据。贝娄我把它放在文件中。

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