Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
Is there a way to implement AJAX in Perl without using the CGI::Ajax module?

I'm trying to create my first site having an AJAX setup using Perl on a free web hosting server. The host has much to be desired. There are Perl modules installed on the server but CGI::Ajax is not installed. I'm new to Perl. Is there a reasonable way to hard-code a simple AJAX setup without using the module I mentioned? Might it have something to do with XMLHttpRequest?

Update: Yeah, I'm reading through the CGI::Ajax module code and comments. I don't suppose I could just extract something out of there and put it into the script that would otherwise call the module? But I'd have to pretty much understand the whole scary module first...

Update: I'm looking into a way to include CGI::Ajax by uploading the module to the same directory as the script that will "use" it, and modifying the @INC path, or something like that...

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

In all the years I've been writing web applications, I have written more than my fair share of Ajax calls and I have never used CGI::Ajax. In fact, until just now I had never heard of it. I've now skimmed the documentation and I really can't see what advantages it gives you.

There are two parts of an Ajax interaction. The client part runs in the browser and is therefore pretty much always written in Javascript. These days, jQuery makes it pretty much trivial. I can't see how a Perl module would help here.

The server part runs on a web server. All you need is an application which receives an HTTP request and sends an HTTP response. A CGI application written in Perl is one obvious way to write that - but these days I'd be far more likely to use something based on PSGI. You'll probably want your application to return data as JSON and set the Content-type header appropriately and perhaps CGI::Ajax helps with that - but it's not exactly onerous to do it in any other web framework.

So, to summarise:

  1. No, you don't need to use CGI::Ajax to write Ajax calls.
  2. It's perfectly possible to write the server end of an Ajax interaction as a Perl CGI program - but in 2017, there are plenty of better options.

Update: So, in this case, you don't need to install the extra module. But, in general, your Perl development life will be far easier if you can get modules installed easily when you want them. So I would very much recommend looking for a hosting solution that allows you to do that.

about 4 years ago · Santiago Trujillo Report

0

There's nothing special about AJAX requests. They are just like any other web request. The following is a sample web (incl AJAX) request handler:

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw( );
my $cgi = CGI->new();
print $cgi->header('text/plain');
print "Hello, World!\n";
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!