【发布时间】:2015-07-28 05:33:24
【问题描述】:
我有一个按钮,按下时必须从外部 php 文件中调用一个函数并将其加载到新页面中。
当我单击 index.php 页面上的“SHOW”按钮时,它会显示“mesaj”中的消息保留,但会在 index.php 页面中显示它(我不想要!)。
我想要完成的是,当我单击 index.php 上的“SHOW”按钮时,它会将消息的内容显示到另一个 php 页面中,名为 - 例如 - content.php。我想设置href。
index.php
<input type = "button" class="btn btn-primary" id = "show" onClick = "show()" value = "SHOW"/>
functions.php
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(json_encode(array("mesaj" => "Entered data successfully ")));
}
function.js
function show(){
var n = $('#show').val()
$.post("functions.php", {show:n}).done(function(mesaj){
//$(document).html(mesaj);
document.write(mesaj);
});
}
【问题讨论】:
-
“我想在 index.php 中设置 href.”是什么意思?
-
@amar 如果我说清楚的话:D alert(mesaj)
标签: javascript php jquery html href