JQuery .get()不从Perl脚本返回HTML

时间:2013-04-15 20:12:52

标签: jquery html ajax get

我有一个小小的问题。我刚开始玩JQuery .get()来调用pl脚本并从脚本返回数据。我现在正在使用以下功能进行电子邮件验证:

$('#billemail').blur(function() {
    if ($(this).val() != '') {
            $.get('./ajax_email_check.pl',{'email':$('#billemail').val() },function(data){
            if (data == "Not Valid") {
                    alert ("Billing email is " + data + "!");
            }
            });
    }
});

以上工作正常。现在我正在尝试返回一些生成,打印和返回的HTML,这是基于用户选择下拉选项并按下按钮。看起来我得到的是null返回而不是返回。如果我运行pl脚本,它将返回我正在打印的内容而没有问题。我正在做以下事情:

JQuery的:

$('body').on('click', '#promotionbtn', function() {
            $.get('./ajax_get_promotion.pl', {'promo':$('select.promoselect').val() }, function(data) {
                    $('.result').html(data);
            });
});

的Perl:     #!的/ usr / bin中/ perl的

use DBI;
use CGI qw(:standard);
require "./lib/servervars.pl";
require "./lib/common.pl";

#my $cgi = new CGI;

#print $cgi->header;

our $dbh;

my $promotion_code = param('promo');

my $promo_handle = "select PromoCode, FirstBillDate, DaysWaivedBilling,  RegistrationFee, RegistrationFeePaidBy, RegistrationDiscountPct, InvoiceDiscountPct, ReferralFee, PromotionTitle, PromotionMessage from Promotion where PromoCode='COMATTACH1'";
my $promotion;

my $getpromo = &db_connect($promo_handle);
while (my @promos = $getpromo->fetchrow) {
    $promotion .= "$promos[0]";
}

$getpromo->finish;

print "content-type:text/html\n\n";
print $promotion;

0 个答案:

没有答案