$.ajax({
url: "notifications.php",
dataType: "json",
success: function(responseJSON) {
if (responseJSON.length > 0) {
document.title = document.title.replace(/^(?:\(\d+\))?/, "(" + responseJSON.length + ") ")
for (var i=0; i<10; i++) {
console.log(responseJSON[i].date_notify')
}
}
}, error : function(x) {
console.log(x.responseText)
}
})
在chrome中我有这个错误:
未捕获的类型错误:无法读取未定义的属性“日期通知”
我发现这部分for (var i=0; i<10; i++)
应该被替换为for (var i=0; i<responseJSON.length; i++)
问题是我只想有 10 个结果......在我的 sql 部分我没有限制查询。这是我的查询
SELECT users.lastname, users.firstname, users.screenname, notifications.notify_id,
notifications.tagged_by, notifications.user_id, notifications.post_id,
notifications.type, notifications.action, notifications.date_notify,
notifications.notify_id
FROM website.users users INNER JOIN website.notifications notifications
ON (users.user_id = notifications.user_id)
WHERE notifications.user_id = ? and notifications.action = ?
ORDER BY notifications.notify_id DESC
//LIMIT 10
有没有办法改变这个?