in reply to Re^5: Server-side processing?
in thread Server-side processing?
This is what i tried, and still not working. it just hangs on Processing...
i first made sure that i get well structured json
#!/usr/bin/perl -wT use strict; use warnings; use DBI; use JSON; use CGI qw/:standard/; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); my $host = "host"; my $usr = "user"; my $pwd = "pwd"; my $dbname = "datname"; my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, { RaiseError => 1, }) or die $DBI::errstr; my $Test = $dbh->prepare("SELECT idnum, fname FROM dbuser"); $Test->execute(); my (@data,$idnum,$fname); foreach (@data = $Test->fetchrow_array()) { $idnum = $data[0]; $fname = $data[1]; } print "Content-type: text/html\n\n"; my $json = encode_json( { $idnum, $fname} ); print $json;
OUTPUT IS
{"748847":"Jane Deo"}
And this is my html
<!doctype html> <html> <head> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.ne +t/v/bs-3.3.7/jq-3.3.1/dt-1.10.18/datatables.min.css"/> <script type="text/javascript" src="https://cdn.datatables.net/v/bs/jq +-3.3.1/dt-1.10.18/datatables.min.js"></script> <script type="text/javascript" src="https://stackpath.bootstrapcdn.com +/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script> <script> jQuery(function($){ $("#table_id").DataTable({ "processing": true, "serverSide": true, "ajax": "file.pl" }); }); </script> </head> <body> <h1>sample dataTable</h1> <table id="table_id" class="table table-hover"> <thead> <tr> <th>ID</th> <th>NAME</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> </tbody> </table> </body> </html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Server-side processing?
by marto (Cardinal) on Feb 15, 2024 at 10:37 UTC | |
by hippo (Archbishop) on Feb 15, 2024 at 11:59 UTC | |
by marto (Cardinal) on Feb 15, 2024 at 12:18 UTC | |
by frank1 (Monk) on Feb 15, 2024 at 12:32 UTC | |
by marto (Cardinal) on Feb 15, 2024 at 12:50 UTC |