【发布时间】:2016-09-01 19:26:42
【问题描述】:
我正在尝试使用 JSON 编码函数和 Ajax 显示数据库的输出。但是,我在如何传递 html 元素“”和 php“例如”方面遇到了困难。显示来自服务器的数据的变量。我希望使用 json 和 ajax 请求显示输出。谢谢。
这是我的代码
//js
function mpo()
{
$.ajax({
url: "main.php",
cache: false,
success: function(html){
$("#show_div").html(html);
}
});
}
//php
$bu = "<div class='main' style='margin-left:" .($level*60). "px'>";
$bu = "<div class='main_one'>";
$bu = "<div class='main_User'>" .($same[2]) . "</div>";
$bu = "<div class='main_Msg'>" .($same[3]) . "</div>";
$bu = "<div class='main_Date'>" . ($same[4]) . "</div>";
$json =array('bu'=>$bu);
echo json_encode($json);
【问题讨论】: