Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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

Replies are listed 'Best First'.
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 (Prior) 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?
[Corion]: Yay. Traditional finance situation averted. Bonds can be quoted in amounts (1_000_000 EUR) or per unit (1 unit). And a traditional error is to trade 2_000_000 piece when you meant to trade 2_000_000 EUR.
[Corion]: (one of my scripts simply catches high amounts and I phone people making that trade, ideally before the payment is due)
[Corion]: The sad thing is that my script sits at the end of the pipeline and can only look at the payments due today or tomorrow basically, while there are many more systems further up in the pipeline
[GotToBTru]: better late than never, I guess

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-03-29 11:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (347 votes). Check out past polls.