基本上我想要将数据从fetch_javaScript函数传递到database_fetch当我执行我的程序时出现以下错误 TypeError:div为null
有一段时间我能够传递数据database_fetch函数,但准备无法找到。
use strict;
use CGI;
use DBI;
use Data::Dumper;
require ("/usr/local/lib/perl5/site_perl/5.8.8/Class/Accessor.pm");
require ("/usr/local/lib/perl5/site_perl/5.8.8/CGI/Ajax.pm");
my $p = new CGI qw(header start_html end_html h1 script link);
my $ajax = new CGI::Ajax( 'fetch_javaScript' => my $database_fetch );
$p->header(-charset=>'US-ASCII');
print $ajax->build_html($p,\&generateHTML);
sub generateHTML
{
my %lable_fund=("Select"=>"Select",
"PMF"=>"PMF",
"PRAMERICA"=>"PRAMERICA",
"DHL"=>"DHL",
"EMF"=>"Edelweiss MF"
);
my %lable_agent=("Select"=>"Select",
"Gyanesh"=>"Gyanesh",
"Satish"=>"Satish",
"Sailesh"=>"Sailesh",
"ArchanaMuluguru"=>"Archana",
"Santosh"=>"Santosh",
"Priyanka"=>"Priyanka"
);
my $datepicker = "datetimepicker.js";
my $jquery = "cal.gif";
print $p->header();
print $p->start_html('MFS CALL CENTER');
print $p->h3('MFS CALL RECORDINGS');
print $p->start_html(-title=>'What we think we become',
-text=>'black',
-bgcolor=>'Gray',
-lang => "javascript",
-script => [{ -type => 'image/gif',
-src => $jquery },
{ -type => 'text/javascript',
-src => $datepicker },
],
);
print "Fund Name ",$p->popup_menu(-name=>'fund',
-id => 'fund1',
-values =>['Select','PMF','PRAMERICA','JM','DHL','EMF'],
-default => 'Select',
-multiple=>'true',
-labels => \%lable_fund),"\n";
print "<P>";
print "Agent Name ",$p->popup_menu(-name=>'agent',
-id => 'agent1',
-values=>['Select','Gyanesh','Satish','Sailesh','ArchanaMuluguru','Santosh','Afreen','Salman','Balaji','Priyanka'],
-default => 'Select',
-multiple=>'true',
-labels => \%lable_fund),"\n";
print "<P>";
print "From Date ", qq`<input name="timestamp" id="demo3" type="text" size="18"><a href="javascript:NewCal('demo3','ddmmmyyyy',true,24)"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>`;
print " To Date ", qq`<input name="timestamp1" id="demo4" type="text" size="18"><a href="javascript:NewCal('demo4','ddmmmyyyy',true,24)"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>`;
print "<P>";
print $p->button(-name=>'Submit',-value=>'Submit',-onclick=>"fetch_javaScript(['fund1','agent1','demo3','demo4'],['id1','id2','id3','id4','id5'],'GET');return true;");
print $p->end_html;
}
$database_fetch =sub
{
my @Details;
# my ($service_name,$agent_name,$call_start_time,$call_end_time);
my $service_name = shift;
my $agent_name=shift;
my $call_start_time=shift;
my $call_end_time=shift;
# print "$service_name ","$agent_name","$call_start_time ","$call_end_time ";
my $call_rec_file_name;
my $DSN = q/dbi:ODBC:SQLSERVER/;
my $uid = q/ivr/;
my $pwd = q/ivr/;
my $DRIVER = "Freetds";
my $dbh = DBI->connect($DSN,$uid,$pwd) or die "Coudn't Connect SQL";
my $servernumber = 2;
my $sql_fund=("select count '$service_name' from cti_services where service_name='$service_name'");
my $fund_count;
my $sql_fund1 = $dbh->prepare($sql_fund);
$sql_fund1->execute();
$sql_fund1->bind_columns(\$fund_count);
$sql_fund1->fetch;
my $sql_agent=("select count(agent_name) from cti_agents where agent_name=?");
my $agent_count;
my $sql_agent1 = $dbh->prepare($sql_agent);
$sql_agent1->execute($agent_name);
$sql_agent1->bind_columns(\$agent_count);
$sql_agent1->fetch;
if( $fund_count == 1 && $agent_count == 1 )
{
my $sql="select top(10) service_name,agent_name,call_rec_file_name,call_start_time,call_end_time from cti_agents join cti_call_master on (agent_name = call_agent_name) join cti_services on (call_service_id = service_id) where agent_name = 'Sailesh' and call_rec_file_name is not null";
my $sth = $dbh->prepare($sql);
while (my @data = $sth->fetchrow_array())
{
@Details=@data;
return @Details;
}
}
}
提前致谢
答案 0 :(得分:0)
您在分配前使用$database_fetch
。您应该将呼叫更改为
my $ajax = CGI::Ajax->new(fetch_javaScript => \&database_fetch);
和
的子程序定义sub database_fetch {
...
}