Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

273
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda