weixin_33725272 2013-02-15 09:50 采纳率: 0%
浏览 70

来自PHP的Ajax多个回显

Say, I have a php file like this:

<?php 
echo 1;
//some functions
echo 2;
//more code to execute
echo 3;
?>

And I have an html form. So what I want in this form is to print echos in some textfield while PHP script is being executed, is it possible with AJAX and JQuery?

What I want is that user enters HTML page, presses some button, this button runs PHP script and every time script reaches echo he can see this echo in textfield. Once script is over - I want to do some JQuery action, like hide button, for example. Is it possible? What would an overview algorithm be? Thanks!

UPDATE:
I need to run this script ONCE when user presses button, but update textfield every time script reaches next echo, so that user presses button once, than he will see "1" in textfield, in a second he will see "2", in few more seconds - "3".

  • 写回答

5条回答 默认 最新

  • weixin_33727510 2013-02-15 09:53
    关注

    Unfortunately, since the success handler of .ajax() will only be called once the request has finished, you can't do a "live update".. :(

    All you can really do is save your current state in a session, end your script at each echo and re-request the page to continue.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题