json结果的jQuery分页

What is the best way of doing a pagination? I would also need to save the current page, so that when I click a link it would save the page I was on. So if I'm on page 2 of the pagination and click one link and then get back to pagination page it would remember that I was on page 2.

I get the results/data from Json request where I have offset and limit possibility.

$.getJSON(base_url+'/ajax/get_news/4/!OFFSET!/!LIMIT!/true', func...

Where !LIMIT! is how many results it shows and !OFFSET! is, well offset :D When I click a link, it makes that request, it goes throught the results and appends the result into page.

What is best way to save the page, cookies? Should I get all the results and then do the pagination somehow or do new request when user change page?

Some tutorial or "hands on" example would be awesome. Normal instructions/guides are difficult to undestand since my first language isn't english.

#0

It appears you have two questions:

1) How to save page state (what page you are on): If the application must continue to use an ajax, then you should look at storing the state in the url as discribed here:

http://ajaxpatterns.org/Unique_URLs

2) Regarding where to do the pagination, I think it would depend on the size of the data to paginate. If it is small and you are not worried about the data changing on between paging, do it all in javascript. Otherwise, do it server-side.

#1

Okey I should use the !OFFSET! and !LIMIT! to do the pagination. I just need change those numbers with pagination links (1 2 3 4 pages etc) to get the pagination to work I believe. But I dont know where to start :/

推荐文章

我的浏览器无法打印出脚本

我的浏览器无法打印出脚本

推荐文章

将web服务与EF一起使用时出现异常

将web服务与EF一起使用时出现异常

推荐文章

这是接受自签名证书的有效方法吗?

这是接受自签名证书的有效方法吗?

推荐文章

如何对多个目录中每个文件的内容执行多个替换?

如何对多个目录中每个文件的内容执行多个替换?

推荐文章

C程序的输出正确吗

C程序的输出正确吗

推荐文章

绘制泥巴图

绘制泥巴图

推荐文章

设计更改电子邮件地址后需要确认邮件

设计更改电子邮件地址后需要确认邮件

推荐文章

Jersey正在获取HTTP 405,路径映射未按预期处理

Jersey正在获取HTTP 405,路径映射未按预期处理

推荐文章

WCF“全局”操作调用程序

WCF“全局”操作调用程序

推荐文章

Codeigniter中的结构函数

Codeigniter中的结构函数

推荐文章

Java或Scala程序员的玩弄技巧

Java或Scala程序员的玩弄技巧

推荐文章

EAI_NODATA和EAI_ADDRFAMILY未声明(Linux操作系统)

EAI_NODATA和EAI_ADDRFAMILY未声明(Linux操作系统)

推荐文章

“核心数据生成代码”是否可以移动到一个由两个目标使用相同数据模型共享的超类?

“核心数据生成代码”是否可以移动到一个由两个目标使用相同数据模型共享的超类?

推荐文章

Maven:在内部使用依赖标记pom.xml文件不同模块的文件

Maven:在内部使用依赖标记pom.xml文件不同模块的文件

推荐文章

叮当:错误:链接器命令失败,退出代码为1

叮当:错误:链接器命令失败,退出代码为1

推荐文章

如何创建6个字符的永久链接?

如何创建6个字符的永久链接?