php 如下
errno){
die($mysqli->error);
};
$mysqli->set_charset("utf8");
$sql = "select * from pinzhi where page=$page";
$res=$mysqli->query($sql);
$result=$res->fetch_all(MYSQLI_ASSOC);
echo json_encode($result);
ajax写法这样写
$.ajax({
url: 'index.php',
type: 'GET',
dataType: 'json',
data: {page:1},
success:function(res){
this.itemList=res;
console.log(res)
}.bind(this)
})
需要注意php的头部要改成 text/json;
同时暴漏的echo 要加json_encode 转化