Attempting to convert an Ajax example to use perl rather than php

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;}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top