You need the response to be
{"records":[{"email":"test@test.com","name":"test"} ..
Try
#!/usr/bin/perl -w use strict; use warnings; use CGI; use DBI; use JSON; my %output=(); my $dbh = DBI->connect("dbi:mysql:database=test","usern","userp") or die "Connecting from Perl to MySQL database failed: $DBI::errstr" +; my $sth = $dbh->prepare('SELECT name, email FROM user_tb'); $sth->execute; while ( my $row = $sth->fetchrow_hashref ){ push @{$output{'records'}}, $row; } my $cgi = CGI->new; print $cgi->header( 'application/json' ); print to_json( \%output );
or leave cgi and change the html. Remove .records and use
$scope.names = response.data;or just change last line of cgi to
print to_json( { 'records' => \@output } ); pojIn reply to Re: Perl and AngularJS - Help Required
by poj
in thread Perl and AngularJS - Help Required
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |