A
Angus
Hello
I am trying to convert an Ajax example using PHP to Perl - using standard
GET. The example is from: http://www.w3schools.com/ajax/ajax_source.asp
I changed the Javascript from
var url="gethint.asp";
to:
var url="gethint.pl";And to simplify, my perl code is just
this:#!/bin/perl5 -wuse strict;use CGI ':standard';print "Lisa";But when you
load the web page - ie:<html>
<head>
<script src="clienthint.js"></script>
</head>
<body><form>
First Name:
<input type="text" id="txt1"
onkeyup="showHint(this.value)">
</form><p>Suggestions: <span id="txtHint"></span></p> </body>
</html>nothing happens. If I simply load the url <url>/clienthint.pl?q=Jane
then nothing happens either.Is there something I am missing in the Perl
code? Is there some special processing for CGI and Ajax?Angusp.s. here is
the javascript code if you need to look at it.var xmlHttpfunction
showHint(str){if (str.length==0) {
document.getElementById("txtHint").innerHTML="";
return; }xmlHttp=GetXmlHttpObject()if (xmlHttp==null) { alert ("Your
browser does not support AJAX!"); return; }var
url="clienthint.pl";url=url+"?q="+str;url=url+"&sid="+Math.random();xmlHttp.
onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(nu
ll);}function stateChanged(){if
(xmlHttp.readyState==4){document.getElementById("txtHint").innerHTML=xmlHttp
..responseText;}}function GetXmlHttpObject(){var xmlHttp=null;try { //
Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) {
// Internet Explorer try { xmlHttp=new
ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new
ActiveXObject("Microsoft.XMLHTTP"); } }return xmlHttp;}
I am trying to convert an Ajax example using PHP to Perl - using standard
GET. The example is from: http://www.w3schools.com/ajax/ajax_source.asp
I changed the Javascript from
var url="gethint.asp";
to:
var url="gethint.pl";And to simplify, my perl code is just
this:#!/bin/perl5 -wuse strict;use CGI ':standard';print "Lisa";But when you
load the web page - ie:<html>
<head>
<script src="clienthint.js"></script>
</head>
<body><form>
First Name:
<input type="text" id="txt1"
onkeyup="showHint(this.value)">
</form><p>Suggestions: <span id="txtHint"></span></p> </body>
</html>nothing happens. If I simply load the url <url>/clienthint.pl?q=Jane
then nothing happens either.Is there something I am missing in the Perl
code? Is there some special processing for CGI and Ajax?Angusp.s. here is
the javascript code if you need to look at it.var xmlHttpfunction
showHint(str){if (str.length==0) {
document.getElementById("txtHint").innerHTML="";
return; }xmlHttp=GetXmlHttpObject()if (xmlHttp==null) { alert ("Your
browser does not support AJAX!"); return; }var
url="clienthint.pl";url=url+"?q="+str;url=url+"&sid="+Math.random();xmlHttp.
onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(nu
ll);}function stateChanged(){if
(xmlHttp.readyState==4){document.getElementById("txtHint").innerHTML=xmlHttp
..responseText;}}function GetXmlHttpObject(){var xmlHttp=null;try { //
Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) {
// Internet Explorer try { xmlHttp=new
ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new
ActiveXObject("Microsoft.XMLHTTP"); } }return xmlHttp;}