Mercurial > boosterpack
view scripts/pjx_JSON.pl @ 3:2e849c856026 boosterpack
[svn r5] it works!
author | robert |
---|---|
date | Tue, 08 Sep 2009 05:55:51 -0400 |
parents | 477258d09353 |
children |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe2 use strict;3 use CGI::Ajax;4 use CGI;6 my $q = new CGI;8 my $Show_Form = sub {9 my $html = "";10 $html .= <<EOT;11 <HTML>12 <HEAD><title>CGI::Ajax JSON Example</title>13 <script>14 handle_return = function(vv){15 document.getElementById('object_display').innerHTML = vv;16 eval(vv); // this gives you 'var jsonObj' here in javascript;17 // alert(jsonObj);18 var div = document.getElementById('parsed');19 div.innerHTML = "</b>key : value<b><br/>";20 for(var key in jsonObj){21 div.innerHTML += key + " => " + jsonObj[key] + "<br/>";22 }24 }25 </script>26 </HEAD>27 <BODY>28 <H2> Get The Letter Following the One you Enter </H2>29 <form>30 Enter Number:31 <input type="text" id="val1" size="6" value='abc' onkeyup="json(['val1'], [handle_return]);">32 <br/><br/>The JavaScript Object:<br/>33 <div id="object_display" style="width:500px;height:200px;">35 </div>36 <br/> After Parsing (use eval) <br/>37 <div id="parsed" style="width:500px;height:200px;">39 </div>41 </form>42 </BODY>43 </HTML>44 EOT46 return $html;47 };49 my $pjx = CGI::Ajax->new('json' => 'pjx_JSON_out.pl');50 $pjx->JSDEBUG(1);51 $pjx->DEBUG(1);52 print $pjx->build_html($q,$Show_Form); # this outputs the html for the page