我正在添加截圖,並且您可以發現問題。使用Ajax分頁HTML輸出正在破解
當我點擊下一個按鈕時,第一行第一列被更改,但第一行第二列未改變而不是第一行,第三列被替換。爲什麼它不會取代第一行第二列?
jQuery('document').ready(function() {
jQuery('.next-page').click(
function(event) {
event.preventDefault();
url = jQuery(this).attr('href');
jQuery.ajax({
url: url,
context: document.body
}).done(function(data) {
console.log(data);
//console.log(data.nextlink);
//console.log(data.previousLink);
//console.log(jQuery('.report-table>tbody>tr>td').is('td'));
posts = data.rows;
jQuery('.report-table>tbody>tr>td:eq(0)').replaceWith(posts[0][0]);
jQuery('.report-table>tbody>tr>td:eq(1)').replaceWith(posts[0][1]);
for(i = 0; i < posts.length; i++) {
for(j = 0; j < 7; j++) {
//jQuery('.report-table>tbody>tr>td:eq(' + j + ')').replaceWith(posts[i][j]);
//console.log(jQuery('.report-table>tbody>tr>td:eq(' + j + ')').is('td'));
//console.log(i + " => " + j + " => " + posts[i][j]);
}
}
});
});
});
下一個按鈕,點擊
之前下一個按鈕點擊後
嘗試從1開始eq()而不是0. – momouu
@ monace19對不起,但這不是解決方法或解決方法。如果它不起作用,您可以提出一些想法嗎?你可以注意到代碼,我已經提出了測試,這將是一個應用程序循環。 –