0
我能夠顯示前兩個帖子和一個按鈕「加載更多」,但當我按「加載更多」按鈕時,它仍然獲得相同的兩個職位。 你能看看我的代碼,並幫我找到錯誤。jquery加載相同的帖子,而不是追加新的帖子
$("#load_more_posts").click(function() {
var offset = offset+limit;
$.post('cont/get_list', {limit: limit, offset: offset}, function (data) {
if (data.message !== undefined) {
$("#list_is_not_got").text(data.message);
} else {
var item = $('<div>');
$.each(data.results, function(i, res) {
var info = $('<p>');
info.html(res.post_text+'<hr>');
item.append(head,info);
});
$("#list_is_got").html(item);
}
}, "json");
});
這幾乎似乎更有點後端問題。你可以粘貼你的後端代碼嗎?服務器回覆什麼? – 2014-09-02 16:46:32
服務器帶回了前兩個帖子,正如我在我的問題中提到的。問題出在我的jQuery代碼中。 { 「結果」:[{ 「POST_TEXT」: 「好」},{ 「POST_TEXT」:「酷」}]} – EducateYourself 2014-09-02 16:56:17