How Do I Make An Ajax Request To Perl Script Using Jquery Blur Event?
Solution 1:
You appear to have written a command line script, designed to be interacted with by a user running it in a shell. (The use of Getopt is a big clue here).
In order to have it respond to an HTTP request you need to rewrite it so that it will work with a webserver (instead of a shell).
There are several ways to do this. A simple approach would be to use CGI. A modern approach would be to use Plack, possibly in conjunction with a framework.
A basic introduction to using Perl/CGI with Apache is available in the Apache documentation. You should look at a module such as CGI in order to process incoming data and emit HTTP headers correctly.
You can find out more about Plack from the project's homepage, which includes links to a number of frameworks that use it.
Solution 2:
That worked for me, call it in the blur event:
functionperlExecute(name){
XMLHttp.open("GET", "/cgi-bin/balance.pl?cardnumber="+name, true);
XMLHttp.onreadystatechange = function() {
if (XMLHttp.readyState == 4) {
$("#balance").val(XMLHttp.responseText);
}
}
XMLHttp.send(null);
};
Post a Comment for "How Do I Make An Ajax Request To Perl Script Using Jquery Blur Event?"