Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by msinfo (Sexton)
on Sep 01, 2013 at 17:53 UTC ( #1051837=note: print w/ replies, xml ) Need Help??


in reply to Re: 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.

Thanks poj

The Show_HTML sub should return the html, not print it

I learned that from you.

The error message goes away, when I use code format shown by you. But, when conditional statement is inserted, in between, it fails. Error says - problem at if condition. When I remove if condition, all goes well.

my $html = $session->header(); $html .= $cgi->start_html(-charset=>'UTF-8',-style => {'src' => 'sty +lesheet/style.css'}); $html .= $cgi->div({-id=>'container'}, $cgi->img({src=>'images/pic.png', height=>'100px', + width=>'150px'}), if ($cgi->p(($session->is_expired) || ($session->i +s_empty)) =1) { $cgi->p("logged") }, $cgi->div(


Comment on Re^2: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
Download Code
Re^3: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
by Anonymous Monk on Sep 01, 2013 at 18:26 UTC

    Doctor Doctor it hurts when I do this, but it doesn't hurt when I don't do it

    Ok then :)

      ;-) If it's not humor, then, I didn't understand

      So can other Perl statements be inserted into above code?

Re^3: CGI::Ajax No head/html tags, nowhere to insert. Returning javascript anyway.
by poj (Priest) on Sep 01, 2013 at 19:34 UTC
    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

      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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-09-19 02:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls