weixin_33712987 2012-05-07 22:00 采纳率: 0%
浏览 90

使用Ajax刷新ob_flush

Ok so I have created a wizard and everything works great. But I have one little piece that seems to 'bother' me if you will.

In the last step of the wizard I build, it uses obflush to process data onto the screen to show some actions happening. But the problem with that is, that the 'entire' page doesn't load until the obflush process is done, and then the page all lines up nicely and such.

Im wondering if there is such a way that maybe ajax can flush the obflush process?

Maybe this is completely wrong but this is how I can envision it happening.

User goes thru the wizard and gets to the final page The entire page loads At the end of the page is some ajax code to apply to a tag maybe The ajax is refreshing itself every second to check against the update of the obflush and then outputting what the obflush has outputted to the screen.

Does that make sense?

Any insight is greatly appreciated.

Thanks

  • 写回答

1条回答 默认 最新

  • weixin_33720186 2012-05-07 22:20
    关注

    This question is about how to load part of a web page with Ajax. In particular, how to load the structure of a page, and then fill in the details with Ajax calls.

    I assume the intention is for the structure to be loaded quickly because it does actually have some content, and then load parts of the page that take a long time to process. Otherwise the effect on screen will be that loading is actually slower.

    I would use the JavaScript library jQuery to help with this, although it can be done without any libraries as shown in this question.

    • The browser makes a web page request and the server responds like it would normally, but just with the structure of the page

    • Within the basically empty page that was loaded, jQuery will then make an Ajax call with load() that will load the response from a URL into the specified HTML section.

    The code would look like this, where my-intro-div is the id of a regular HTML div tag:

    $(function() {
        var myIntroDiv = $('#my-intro-div');    
    
        myIntroDiv.load('/my_intro_div.php');
    });
    
    • The PHP script my_intro_div.php returns the HTML that is meant to be displayed inside the my-intro-div tag

    There are some good examples in the jQuery documentation here:

    http://api.jquery.com/load/

    jQuery can help with a tonne of other things too. It has a tiny learning curve that can be a little steep, but after that I've found that it is the most intuitive "language" I work with.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝