in reply to Simple CGI::Ajax

Your message is extremely unclear... First you should fix formatting, and post code examples into <code> tags. See How (Not) To Ask A Question

BTW, regarding CGI::Ajax, you may want to have a look at the documentation and the mailing list on http://groups.google.com/group/cgiajax.

Last, CGI::Ajax doesn't replace CGI, it simply complete it. You may use them both. I suggest that you try getting something working as a simple CGI first, then complete it with CGI::Ajax

Replies are listed 'Best First'.
Re^2: Simple CGI::Ajax
by david.shapiro (Initiate) on Jul 25, 2007 at 15:33 UTC
    Sorry it is unclear. I have something kind of working,but not really working. When I click on the Update button, I see my post appear on the screen (ie., healthchk.cgi?fname=displayText&args=Update&update=Update) for a second and then it flashes off the screen instead of the text I was expecting from the &displayText function. Here is part of the code:
    #!/usr/opt/perl5/bin/perl -Tw use CGI; use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use CGI::Ajax; use strict; use warnings; use English; use Env qw(PATH IFS CDPATH EMV BASH_EMV); $ENV{PATH} = "/bin:/usr/bin:/usr/local/AppAdmin/healthchk/bin:/usr/loc +al/healthchk/bin"; delete @ENV{ 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; my $home = "/usr/local/AppAdmin/healthchk"; my $html = ""; my $cgi = CGI->new(); my $ajax = CGI::Ajax->new(displayText => \&displayText ); $ajax->JSDEBUG(1); print $ajax->build_html($cgi,\&main); sub main() { $html = <<HTML; <html> <head> <title>Siebel HealthCheck</title> <LINK href="/healthchk/style.css" rel="stylesh +eet" type="text/css"> </head> <body> <table class="banner" border="0" cellspacing="0" cellp +adding="0" bgcolor="#000000"> <tr valign="top"> <td class="banner" width="10%"> <img src="/healthchk/images/bc +bsnc.gif" width="100%" > </td> <td class="banner" width="80%"> &nbsp; </td> <td class="banner" width="10%"> <font align="right" size="1px" + color=white>&#169; 2007 David Shapiro</p></font> </td> </tr> </table> <h1>Siebel HealthCheck</h1> HTML # Do something print_response() if $cgi->param; my $url = $cgi->url(-relative => 1); $html .= <<HTML; <form action="$url" method="post"> <center> Environment&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="ALL" >&nbsp;ALL&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="prod">&nbsp;prod&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="pstage">&nbsp;pstage&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="qa">&nbsp;qa&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="dev">&nbsp;dev&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="pmt">&nbsp;pmt&nbsp;&nbsp; <input type="checkbox" class="cbox" name="envi +ronment" value="sand">&nbsp;sand&nbsp;&nbsp; <br><br><input type="submit" value="Submit" cl +ass="btn"> <input type="submit" id="update" onClick="disp +layText(['update'],['displayDiv']);" value="Update" class="btn"><br>< +br> </center> </form> <div id="displayDiv"></div> </body> </html> HTML return $html; } sub displayText() { my $text = shift; $html .= <<HTML; <h2>Updating status...</h2> HTML return; }
Re^2: Simple CGI::Ajax
by wazoox (Prior) on Jul 26, 2007 at 13:23 UTC
    It looks like you're not sending any headers. I renew my first suggestion : get the script simply working first, then "ajaxify" it. I advise you to use Firefox plus Live HTTP headers to see what's coming from and to your browser, too.