Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

CGI javascript AJAX - progress in real time on a web page.

by Caesura (Sexton)
on Sep 23, 2009 at 11:55 UTC ( [id://796945]=perlquestion: print w/replies, xml ) Need Help??

Caesura has asked for the wisdom of the Perl Monks concerning the following question:

Hello Fellows, Perl CGI : Can anyone tell me how to show real-time progress of a loop doing stuff onto a web page, perhaps using Ajax? I have a submit button which calls a subroutine which loops round a list of items and processes them - I'd like to show the results of the process in real time onto the web page, so that the user can see whats happening, 'cos it takes a long time. I have actually just printed the results to the browser, and that works except it's never a proper web page (<html> to </html> until its finished. I could write the results to a file continually, and have a separate web page read it on auto-refresh, but I don't like that method - don't like to have too many tmp files about the place. It can be done withh Ajax and javascript, but my prog is in Perl ... Any help would be much appreciated! Cheers Caesura
  • Comment on CGI javascript AJAX - progress in real time on a web page.

Replies are listed 'Best First'.
Re: CGI javascript AJAX - progress in real time on a web page.
by Bloodnok (Vicar) on Sep 23, 2009 at 11:59 UTC
    Did you use Super Search ? I did and found this to name but one.

    A user level that continues to overstate my experience :-))
      Thanks Bloodnok, my node-title-creating skills are not the same as my search-term-forming skills, obviously!

      That example, though, that you found seems to have this :
      print '<header>'; # placeholder for your whole HTML header block print '<span id=Progress>Working...</span>'; print '<footer>'; # placeholder for the rest of your document until bu +t without </body>

      I'm not sure what the header and footer tags are here, and still the web page is incomplete until the process finishes and the browser gets its </body></html> tags.

      I noted this Watching long processes through CGI Aug02 which runs a bg process to do the work, but stopping the browser lets it go on, I'd rather not have that. And he bangs on about "server push" which is what I'm already doing (just printing the progress to the screen after the html headers), and the browser/server probs that could have.

      Looks like I'm stuck with :
      • server push
      • write to a file or process and read it in a separate web page
      Is there not a way to print a whole web page then update elements of it like Ajax does?

      Thanks much for the help!

      Caesura
        I have to admit that I searched for 'CGI' & 'progress' - I completely overlooked the prime requirement i.e. _browser_ progress reporting, so the server push probably ought not to be a surprise.

        As to your supplementary question, 'tis a good guestion well asked !! :-D

        If you are fortunate enough to find/develop a solution, please be sure to enlighten some/all of the monks by posting it [the solution] here (on the monastry) - esp. if it's a perl based solution.

        A user level that continues to overstate my experience :-))
        Is there not a way to print a whole web page then update elements of it like Ajax does?

        Yes, it is called AJAX, and there is no ajax without javascript.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://796945]
Approved by Bloodnok
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-19 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found