我在读取 JSON 数据时遇到问题。
模型.php
class chatApp extends database{
public $row = array();
public function IO(){
//SELECTING FROM DATABASE MAKE QUERY ....
$this->row = $mysql->show; //result
return $this->row; //return it
}}
控制器.php
if(isset($_GET['showmessage'])){
$chatApp = new chatApp(); // chat app object
$row = $chatApp->IO();
echo json_encode($row);} // echo it like json
视图.php
function update(){
$.ajax({
type: "POST",
url: " http://localhost/chat/controller.php?showmessage",
dataType: 'json',
success: function(data) {
$("#chat").html(data); //The data ?
}
});
} setInterval (update, 1000);
所以问题是我无法在聊天 div 中显示数据?我做错了什么