How can I continuously inform the user of progress from a Perl CGI script?

前端 未结 6 701
一整个雨季
一整个雨季 2021-01-13 12:04

I have this Perl script sitting in the cgi-bin folder of my Apache server:

#!/usr/bin/perl 
use strict;
use warnings;

$| = 1;

print \"Content-type: text/ht         


        
6条回答
  •  [愿得一人]
    2021-01-13 12:25

    What you are wanting to achieve is possible -- browsers generally render what it has received so far, even if it is not the complete document, provided there is sufficient markup to be able to render anything at all. I'm wondering however why you use \r\n for some output and just \n for others -- you should be consistent and use \n throughout. Additionally, you are specifying a content type of text/html, but not providing any html headers () before your content.

    However, the "modern" way to do this is to return the page output immediately, but leave the part you want to update later as an empty

    element. Then you can update the content of that element with javascript (via an AJAX request).

提交回复
热议问题