CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Ajax calls SVN by using perl, How to print result line by line instead of all at once

 



canadatom
New User

Feb 8, 2010, 7:03 AM

Post #1 of 5 (583 views)
Ajax calls SVN by using perl, How to print result line by line instead of all at once Can't Post

Hi guys,

I am new to perl, I am not sure this is Ajax related question or perl, if someone knows how to do, please advise.

I am writing a very simple small app which uses a HTML frontend, by using Ajax to call my perl script which runs SVN checkout, updates etc.

I don't have any problem with running this perl script in command line or calling from Ajax.

My only problem is when I call this perl script from Ajax in HTML, all output result will only come out at once, instead of line by line, is there anyway to do this kind of output?


FishMonger
Veteran / Moderator

Feb 8, 2010, 7:10 AM

Post #2 of 5 (581 views)
Re: [canadatom] Ajax calls SVN by using perl, How to print result line by line instead of all at once [In reply to] Can't Post

Sounds like you need to disable output buffering.

See if adding this near the beginning of the script solves your porblem.


Code
$|++;



canadatom
New User

Feb 8, 2010, 8:00 AM

Post #3 of 5 (579 views)
Re: [FishMonger] Ajax calls SVN by using perl, How to print result line by line instead of all at once [In reply to] Can't Post

Thanks for your reply, the output result still comes out at once, would you give me a sample example on how HTML reponses to perl output in real time line by line?

Thanks again


FishMonger
Veteran / Moderator

Feb 8, 2010, 8:31 AM

Post #4 of 5 (574 views)
Re: [canadatom] Ajax calls SVN by using perl, How to print result line by line instead of all at once [In reply to] Can't Post


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI;

$|++;

my $cgi = CGI->new;

print $cgi->header,
$cgi->start_html("Output Flush Buffer Test");

for ( 1..10 ) {
print $cgi->p("Line $_");
sleep 1;
}

print $cgi->end_html;



canadatom
New User

Feb 8, 2010, 1:59 PM

Post #5 of 5 (566 views)
Re: [FishMonger] Ajax calls SVN by using perl, How to print result line by line instead of all at once [In reply to] Can't Post

Thanks for your code, and it works,

Question is it only works in firefox, IE7 does not display anything, but I get the idea how this is gonna work.

on Ajax side, I used protoypejs,


Code
// new Ajax.Request(getLauncherPath,    
// {
// method:'get',
// onInteractive: function(transport){
// var response = transport.responseText;

// $('launcher').update(response);
// //$('launcher').innerHTML = response;

// },

// onFailure: function(){
// alert('Something went wrong...')
// }
// }
// );



(This post was edited by canadatom on Feb 8, 2010, 2:04 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives