如何创建增量加载网页 [英] How to create an Incremental loading webpage

查看:68
本文介绍了如何创建增量加载网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个处理大量数据的页面.因为返回的数据太大,它将一直持续到我的结果页面加载(几乎无限).因此,我需要在Thie url上实现一个逐步加载的页面,如

I'm writing a page dealing with a large amount of data. It would last forever until my resultant page loaded (nearly infinite) because the data returned is so large. Therefore, I need to implement an incrementally loading page like one at thie url:

http://docs.python.org/

每次输入搜索词时,它将继续加载,然后加载,直到得到一些结果为止,它将逐步显示,这很酷:D.

Everytime a search term is entered, it will continue to load, and load, until it got some result, it will display incrementally, pretty cool :D.

[edit]我正在使用python CGI(服务器)+ Jquery(客户端).我在这里问过类似的问题:

[edit] I am using python CGI (server) + Jquery (client). I have asked a similar question here :

只要服务器上有数据,就在网页上显示结果

我只尝试在服务器上请求一个脚本,然后让客户端页面以增量方式显示即将出现的结果,这一事实使我感到头痛.如果我没记错的话,长期投票或类似的方法不适用于这种情况吗?

The fact that I am trying to request a script on server ONLY ONE and let the client page incrementally displays out coming results has given me headache. If I don't get in wrong, the long poll, or something like that is not applied to this situation right?

我正在尝试做flush()事情,但是也许我在这里错过了一些东西,我无法使其工作:(,结果总是一次全部出现在客户端上.此外,还要获得前几个字节,前几个结果是非常笼统的术语.我真的很感激可以给我一些运行的代码,因为我现在很困惑.非常感谢.

I am trying to do flush() thing but perhaps I am missing something here, I can not make it to work :(, the result always comes to client all at once. Plus getting the first few bytes, first few results are very general term. I would really appreciated with one can give me some running code, cuz I am very confusing now. Thanks so much.

[edit]当我尝试使用仅调用方式时,我设法关闭了apache2的mod_deflate,但到目前为止,我还是失败了.我用谷歌搜索了这个问题,并且出现了像我这样的一些情况,这不是运气:(.

[edit] As I am trying to stick with call-on-only manner, I manage to shut of the mod_deflate of apache2 but so far I failed. I googled this problem and there comes some cases like myself, it's no luck :(.

推荐答案

有多种可能的方法,但是基本的技巧是让搜索程序在完成之前将结果返回到线路.通常,每隔这么多结果显式调用一次flush()调用或等效调用即可完成此操作.

There are various possible ways to do so, but the basic trick is to have the search program return results to the wire before finishing. This is something usually done by explicitly calling a flush() call or equivalent every so many results.

现在,要展示它们,您可以

Now, to present them you can either

  • 使用AJAX:使用javascript返回一个很小的页面,该页面将触发搜索,这将在刷新结果时使用结果修改DOM(或使用表示多少个参数的参数多次调用搜索程序您想要的结果和偏移量)

  • Use AJAX: Return a very small page with javascript that will trigger the search, which would modify the DOM with the results as they are being flushed (or make several calls to the search program with a parameter denoting how many results you want and the offset)

使用简单的HTML:使用浏览器不等待完成渲染的HTML(这通常避免使用表格,因为通常是在整个表格到达后才渲染表格)

Use simple HTML: Use HTML that the browsers don't wait to complete render (this translates to avoiding tables, mostly, as tables are usually rendered when the whole table has arrived)

当然,如果我们知道您要编程的内容,则可以获得更具体的建议.

Of course, if we knew what are you programming in, you could get more concrete advice.

这篇关于如何创建增量加载网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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