AJAX分页添加数据以替换数据 [英] AJAX Pagination adding data insted of replacing data

查看:137
本文介绍了AJAX分页添加数据以替换数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有效的基于PHP 的分页,正在向其添加ajax以改善页面加载.

I Have a working PHP Based Pagination onto which i am adding ajax to improve page load.

我的问题是ajax将整个导航页面(通过分页链接进行导航)添加到当前页面内容.

my problem is ajax is adding whole navigation page(to which navigation is made through pagination link) to current page content.

要添加的特定数据是用于显示内容的 div 中的整个导航页面.应类似于替换当前页面的内容包含导航页内容.

and to be specific data added is whole navigation page in a div used for content display. which should be like replacing current page content with navigation page content.

我的分页与ul li的 id ="pagination" 在div中. 我重复的页面内容在 id ="temp" 的div中.

my pagination is in div with id="pagination" with ul li. my repeating page content is in div with id="temp".

我的Ajax代码

    $(function(){
$('#pagination ul li a').click(function (ev) {
ev.preventDefault();    
$('div#temp').load($(this).attr('href'));
});
});

我在分页中的navigatin链接结构就是这样

and my navigatin link structure in pagination is like this

echo " <li><a href='is-test.php?page=$nextpage'>Next&raquo;&raquo;</a></li> ";

请告诉我如何使ajax替换插入数据的数据.

please tell me how i can make ajax to replace data insted of adding data.

谢谢.

推荐答案

通常.load()应该替换div#temp的内容.但是您可以通过以下方法解决此问题:

Generally .load() should replace the contents of div#temp. But you can solve this by: following:

$('div#temp').empty();

$('div#temp').load($(this).attr('href'));

 $('div#temp').load($(this).attr('href') + '#temp');

这篇关于AJAX分页添加数据以替换数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆