I am a complete newbie to Perl & Javascript/Jquery/Ajax. As an example, I'd like to send the string var exampleString to test.pl, and the script will then write the string to file.
function sendToScript{
var exampleString = 'this is a string';
$.ajax({
url: './test.pl',
data: exampleString,
success: function(data, textStatus, jqXHR) {
alert('string saved to file');
}
}
test.pl
#!/usr/bin/perl -w
use strict;
#How do I grab exampleString and set it to $string?
open (FILE, ">", "./text.txt") || die "Could not open: $!";
print FILE $string;
close FILE;
Any help would be much appreciated.
exampleString, execute, and save the string to text file on the server; no data will be displayed client-side.