我是一個完整的Perl新手& Javascript/jquery/Ajax。例如,我想將字符串var exampleString
發送到test.pl,然後腳本將字符串寫入文件。如何在Perl腳本中使用JQuery/Javascript變量的值?
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;
任何幫助將非常感激。
你想使用get或post方法發送它嗎? – MikeB 2013-05-03 19:06:39
@MikeB我不得不查看兩者之間的差異,我不得不說不?我只想讓perl腳本抓住字符串變量'exampleString',執行並將字符串保存到服務器上的文本文件中;客戶端不會顯示任何數據。 – Steve 2013-05-03 19:13:14
在這種情況下,您可能想要使用post方法並只抓取消息的整個主體。這就是說,我並沒有試圖變得暴躁,get和post是webapps的基本概念;你可能應該花一點時間瞭解你正在使用的工具。 – 2013-05-03 19:36:14