Jquery Ajax返回从数据库中获取两个不同的值
我有一个普通的ajax函数,它可以发布到php页面并从表中返回一些项 在我尝试设置用户的FB映像之前,一切都很好。我得到了这个错误:Jquery Ajax返回从数据库中获取两个不同的值,jquery,ajax,Jquery,Ajax,我有一个普通的ajax函数,它可以发布到php页面并从表中返回一些项 在我尝试设置用户的FB映像之前,一切都很好。我得到了这个错误: "error": { "message": "Unsupported get request.", "type": "GraphMethodException", "code": 100 } 在检查Chrome的inspect元素时,我注意到一些奇怪的东西 这是网络中的预览选项卡: active: 1 add_date: "2015-03-11 05
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
在检查Chrome的inspect元素时,我注意到一些奇怪的东西
这是网络
中的预览
选项卡:
active: 1
add_date: "2015-03-11 05:28:10"
fb_id: ...828
first_name: "Fname"
id: 468
item_description: "Desc"
item_title: "Title"
user_id: 62
username: ""
这是在Network
[{"id":468,"user_id":62,"item_title":"Title","item_description":"Desc","active":1,"add_date":"2015-03-11 05:28:10","fb_id":...829,"first_name":"Fname","username":""}]
除了递减1的fb_id
之外,其他都是一样的。在用户表中,它以829
结尾
也许我做错了什么
编辑**
阿贾克斯
realpha.php
$selectHome = $ItemTools->selectHome();
echo json_encode($selectHome);
质疑
是否您的数据库在
users
表中的fb\u id
字段中具有自动增量
显示create table语句可能是一个明智的主意。请分享您正在使用的代码。您好。。。很多。您能告诉我在“检查元素”的“预览”和“响应”选项卡中看到的数据之间是否有任何差异吗?为什么只有那个特定领域会受到影响?该行设置为
bigint
。。。如果这有什么区别的话。想看代码只是为了检查您正在获取和发送给客户端的内容。@itzmukeshy7请看我的编辑。刚刚检查了控制台日志。。。它仍然比存储在数据库中的实际fb_id少一个。可能是输入错误,console.log(data[i]fb_id)
应该是console.log(数据[i].fb\u id)代码>(带点)不。。。它在id
字段上具有自动递增功能。
$selectHome = $ItemTools->selectHome();
echo json_encode($selectHome);
public function selectHome() {
if($q = $this->db->mysqli->prepare("SELECT
t1.id, t1.user_id, t1.item_title, t1.item_number, t1.item_start, t1.item_description, t1.active, t2.first_name, t2.last_name, t2.fb_id, b.maxbid, b.bids
FROM
items t1
LEFT JOIN
users t2
ON
t1.user_id = t2.id
LEFT JOIN (
SELECT item_id, bid, MAX(bid) AS maxbid, COUNT(bid) AS bids
FROM bids GROUP BY item_id
) b
ON t1.id = b.item_id
WHERE t1.active = 1
ORDER BY id DESC")) {
$q->execute();
$rows = $this->db->bindResults($q);
$q->close();
return $rows;
}
}