Hi Monks,

I need some help to send results from ajax requests to different divs from an external script.

My HTML code is:

<input type='hidden' id='yyy' value='Hello Y'> <input type='hidden' id='xxx' value='Hello X'> <button id="test" type="button" onClick="test(['xxx','yyy'], ['out1', +'out2'] );">TEST</button><P> Div1: <div id='out1'>.</div><P> Div2: <div id='out2'>.</div><P>
If I use an internal script my perl code is:
### link js func to perl func my $cgi = new CGI(); my $pjx = new CGI::Ajax('test' => \&testAjax); ### perl func sub testAjax { return( @_ ); }
The output shows correctly as
Div1: Hello X Div2: Hello Y

If I use an external script:

### Inside main script my $urlFunc = '/html/cgi/test.pl'; my $pjx = new CGI::Ajax('test' => $urlFunc); ### the file test.pl code: use cgi qw( :standard -debug); my $q = CGI->new; print $q->header; print ($q->param('xxx'), $q->param('yyy'));
it produces this output:
Div1: Hello XHello Y Div2: undefined
Obviously, the print statement concatenates the 2 parameters.

How can I get the external script to produce the same output as the internal function?

Anybody any ideas?

Thanks.


In reply to CGI::Ajax...sending results to different divs by stephanm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.