I want to retrieve a csv file from one online database. However, due to some XSS issues, I cant directly use ajax, but need to relay on a perl-cgi file.
I already had a working perl-cgi file that can query the csv file , and write the content of the file into a perl variable called $text. Here are some code snippets:
#!/usr/bin/perl
use strict;
use CGI;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
# construct cgi object
my $q = CGI->new;
# create a post request
my $useragent = LWP::UserAgent->new();
my $request = POST '.....', [
#something goes here
];
my $response = $useragent->request($request);
my $text = $response->content;
print $text;
I have some general ideas of what to do next, but not so sure about the details. I will upload this perl-cgi file to the server that hosts my website, to the folder called cgi-bin. I just wonder how can I call that perl-cgi file from javascript, and write back the content of $text into javascript varaiable.
Thanks for the help