输出缓冲和AJAX [英] Output buffering and AJAX

查看:84
本文介绍了输出缓冲和AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户单击我网站上的按钮时,页面的特定部分将被刷新,但是渲染整个部分需要一些时间.是否可以实时显示/输出部分内容,而不是等待整个部分结束?如果我将其作为对HTML内容的Ajax请求发送,我该怎么办?谢谢

When a user clicks a button on my site, a particular part of a page will be refreshed, but it takes a while to render the entire section. Is it possible to display/output parts of the section in real time rather than wait for the entire section to finish? How would i do this if im sending it as an ajax request for html content? Thanks

推荐答案

您可以实现Pagelets技术.从本质上讲,您可以按照以下方式进行此操作:

You could implement a Pagelets technique. Essentially you could work this in a way, like below:

index.html
  Ajax -> load content from PHP script which outputs the navigation bar
  Ajax -> load content from PHP script which outputs the body

并且有几个不同的Ajax调用加载了站点的每个不同部分.但是,这样做确实有一个缺点,那就是增加了用户浏览器必须发出的HTTP请求的数量.

And have several different Ajax calls loading each different part of your site. This does have a disadvantage of increasing the amount of HTTP requests the user's browser has to make, however.

这是假定尽管可以与页面的其余部分分别生成不同的部分.如果您需要同时生成所有内容,那么此技术将毫无用处.

This is presuming though that different parts can be generated separately from the rest of the page. If all your content needs to be generated at the same time then this technique will be of no use to use.

这是一本好书(Facebook项目名为"BigPipe"): http://www.facebook.com/note.php?note_id=389414033919

This is of a good read (Facebook project named "BigPipe"): http://www.facebook.com/note.php?note_id=389414033919

这篇关于输出缓冲和AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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