我在我的主要舞者的應用程序的.pm下面的代碼:有沒有一種非常簡單的方法來使用jQuery/AJAX更新Perl Dancer中的頁面?
package Deadlands;
use Dancer ':syntax';
use Dice;
our $VERSION = '0.1';
get '/' => sub {
my ($dieQty, $dieType, $bonus);
my $button = param('button');
$dieQty = param('dieQty');
$dieType = param('dieType');
$bonus = param('bonus');
if (defined $dieQty && defined $dieType) {
return Dice::Dice->new(dieType => $dieType, dieQty => $dieQty, bonus => $bonus)->getStandardResult();
}
template 'index';
};
true;
這裏是我的JavaScript:
$(document).ready(function() {
$('#standardRoll').click(function() {
$.get("/lib/Deadlands.pm", { button: '1', dieType: $("#dieType").val(), dieQty: $("#dieQty").val(), bonus: $("#bonus").val() }, processData);
function processData(data) {
$("#result").html(data);
}
});
});
我在我的網頁一個div叫result
,我要被更新與Perl的模具滾動結果。當我按下提交按鈕時,舞者在命令窗口中不斷返回404錯誤。
哈!那樣做了!非常感謝! – BackPacker777