tacogrande has asked for the wisdom of the Perl Monks concerning the following question:
--- The main template:<script src="/java/jquery-1.3.2.js"></script>
Here is my CGI<form method="post" action="index.pl" enctype="application/x-www-form- +urlencoded" name="reg"> <input type='hidden' name='rm' value='registration +email' /> <font color="red">Username: </font></font><input t +ype="textfield" class="registrationfields" size="10" id="user" name=" +r_username" onkeyup="exported_func( ['user'], ['test']);"> <TMPL_VAR NAME="TEST"> <span id="ajax_spinner" style="display: none;"> <img src="../images/spinner.gif"/></span> <div id="display_user_details"> </div> <div id="test"> </div> <br/> <font color="red">Password: </font><input type="pa +ssword" class="registrationfields" size="10" name="r_password"/> <font color="red">Password-Check: </font><input ty +pe="password" class="registrationfields" size="10" name="r_passwordch +eck"/> <br/> First Name: <input type="textfield" class="registr +ationfields" size="10" name="r_name"/><br/> Last Name: <input type="textfield" class="registra +tionfields" size="10" name="r_lastname"/><br/><br/> Email Validation Required within 24 Hours of Accou +nt Creation.<br/> <font color="red">Email: </font><input type="textf +ield" class="registrationfields" size="10" name="r_email"/> <font color="red">Email Check: </font><input type= +"textfield" class="registrationfields" size="10" name="r_emailcheck"/ +> <br/><br/> Country: <input type="textfield" class="registrati +onfields" size="10" name="r_country"/><br/> City: <input type="textfield" class="registrationf +ields" size="10" name="r_city"/><br/> <br/> How did you find us? <br/> <textarea rows=5 cols=20 class="registrationfields +" name="r_find"></textarea><br/> <br/> <br/> <TMPL_VAR NAME="CAPTCHA"> <br/> <input type="submit" value="Register"/> </form> <script> // show the spinner for AJAX requests $("#ajax_spinner").ajaxStart(function(){ $(this).show(); }); $("#ajax_spinner").ajaxStop(function(){ $(this).hide(); }); $("#user").keyup(function(){ $("div#display_user_details").html(''); $.getJSON('?ajax=1', function(result){ $("div#display_user_details").html( result.username ); }); }); </script>
there is also a sub routine for checking the database, but right now i am just trying to get it to print the value. I have also tried cgi::ajax, but i cant get it to work with cgi::app and html::template, this is a little over my head. Any help is appreciated.sub usernameCheck { my ($query, $self) = @_; #my $enteredusername = $query->param('r_username'); # check if its an AJAX submit if ( $query->param('ajax') ) { my $usernamecheck = check_usernames($enteredusername); my $json = to_json($usernamecheck); print "Content-type: text/html\n\n"; $self->header_add(-type => 'application/json'); print $json; exit; } } sub check_usernames { my ($t) = @_; # pretend like we're doing some heavy task! #my $answer = checkdbforusername($t); sleep 0; my $userresult = { username => $t, }; my $userresult2 = { username => $t, }; if($answer == 1) { return $userresult; } else { return $userresult2; } }
|
|---|