doudieheng5322 2013-09-03 03:12
浏览 12

脚本后输出缓冲内容

At the beginning of my script, I have a function that gets JSON content from a remote server that takes a while. It takes between 1-2 seconds to fetch the data, but that is a ridiculous freeze time for my website's viewers.

What I want to do is to first output all the other content first AFTER the first-line-GET script, and then show the data involving that JSON call after the data has been received.

ex:

<?php

$data = array();
getApiInfo( $user ); //fills $data with info

?>

That's the first few lines, then the next is html content that I want to output immediately, but contains some $data info that cannot.

<div>
    <img src='images/logo.png' />
    <p>Name: <?php echo $data['name']; ?></p>
</div>

Keeping it short, the html afterwards looks sort of like that. What i want to happen is the image and the 'Name:' show immediately, but the $data['name'] doesn't until the call is complete.

  • 写回答

1条回答 默认 最新

  • doutuo3935 2013-09-03 03:27
    关注

    Ajax

    Your back-end script can fill-in the appropriate div/id/element on your generated html when it's done processing, no refresh.

    (Sorry Dagon, didn't see your comment...)

    评论

报告相同问题?

悬赏问题

  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗