Hi
I am slightly confuse with the problem I am facing. Not really sure why, but confuse me a lot. Been seraching the web for anyone with some situation but no luck.let say the following is my code
use CGI::Ajax;
use CGI;
$pjx = new CGI::Ajax ('func','\&func');
$cgi = new CGI;
$html=<<EOF;
... ...
<Script>
var previous_value;
function user_click (current_value)
{
previous_value=current_value;
func([],['change_location']);
}
</Script>
<BODY>
<a href="#" OnClick="user_click(somevalue)">
CLICK ONCE OK, SECOND TIME FAILED
</a>
<div id="change_location"></div>
</BODY>
</HTML>
EOF
sub func()
{
do something ..
return something ..
}
$pjx->build_html($cgi,$html);
Ok, when it is open using browser, everything looks ok
when the link (href) is clicked for the first time, it works
but if it is clicked for the second time, it gave javascript error
At first I thought something wrong with ajax xml generated, but after further test, I figure out the script
previous_value=current_value;
is the cause of the error
As of now, I have workaround using hidden input, however, I wish to know why simple assignment is giving error
maybe somebody have the answer. Thank you
20080520 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.