Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.

by poj (Abbot)
on Sep 01, 2013 at 19:34 UTC ( [id://1051853]=note: print w/replies, xml ) Need Help??


in reply to Re^2: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
in thread CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.

Put the conditional outside the div ;
my $msg = ($session->is_expired || $session->is_empty) ? 'logged':''; $html .= $cgi->div({-id=>'container'}, $cgi->img({src=>'images/pic.png', height=>'100px',width=>'150px'}), $cgi->p($msg),$cgi->div(
poj
  • Comment on Re^3: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
  • Download Code

Replies are listed 'Best First'.
Re^4: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
by msinfo (Sexton) on Sep 01, 2013 at 21:32 UTC

    Sorry to all of you, but it's not working. Let me clear myself, I wanna write a CGI script, which would do following.

    # required modules use CGI; use CGI::Ajax; # html generation depending upon session info # begining html code if ($session-start) print $cgi->p("user no" . $session->id); else print $cgi->p("guest"); # remaining html code # ajax call my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func); print $pjx->build_html($cgi, \&htm);

    I am finding it difficult to generate HTML content with session info, and forward it to Ajax call

    If it wouldn't have been Ajax call, then, manipulating HTML content depending upon session info was easy part for me.

        Hi, Anonymous Monk Thanks for your calm advice and code. Below is code which worked.
        $html .= $cgi->div({-id=>'container'}, $cgi->img({src=>'images/pic.png', height=>'100px', + width=>'150px'}), ( (($session->is_expired) || ($session->is_empty)) ? ($cgi->p("false")) :($cgi->p("true")) + ), $cgi->div( {-id=>'menu_bar'}, # rest of html

        And here is code, which didn't

        $html .= $cgi->div({-id=>'container'}, $cgi->img({src=>'images/pic.png', height=>'100px', + width=>'150px'}), ( (while ($num <=5) {($cgi->p($num)) ($num++)}) ), $cgi->div( {-id=>'menu_bar'},

        What I did wrong in 'while' case. I went through links, provided by you. So here $html .= $cgi->div#rest of code, is one big statement and rest of part on right side are expressions.

        But, could not grasped the concept and structure behind parenthesis well.

        And is it possible to use other Perl blocks in this fashion.?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-24 06:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found