Note that there are some explanatory texts on larger screens.

plurals
  1. POApplying Ajax asynchronously upon a table designed in HTML (.tmpl file) and retrieves data through Perl (.cgi file)
    primarykey
    data
    text
    <p>I have 2 seperate linked file -> (1) .cgi (Perl file for retrieving data from a URL), and (2) .tmpl (HTML Template where the table has been constructed). Both have been linked up through HTML::Template.</p> <p>I need to refresh the contents of the Table rows asynchronously, say every 20 seconds. For the same, I have created the various div ids in the .tmpl file which need to be refreshed.</p> <p>The following are the codes: 1. Perl Code (.cgi file, retrieves the content of the table):</p> <pre><code>#!/Dwimperl/perl/bin/perl use strict; use warnings; use LWP::Simple; use HTML::Table; use HTML::TableContentParser; use HTML::Template; use CGI; print "Content-type: text/html\n\n"; my $template = HTML::Template-&gt;new(filename =&gt; 'tryin.tmpl'); my $cgi = new CGI; use CGI::Carp qw(fatalsToBrowser); #1====================================================== #------------------------------------------------------- #Fetching AIRTEL HVP1 #------------------------------------------------------- my $URL1= "http://****/server1"; my $content1 = get($URL1); my $str12; my $count13; my $count14; my $str15; my $str16; # GHANA TIME #2------------------------------------------------------ # FOR IP # #------------------------------------------------------- my $value1=0; my $value2=0; if ($content1 =~ m/IP/g) {$value1=pos($content1);} if ($content1=~m/Blocked/g) {$value2=pos($content1);} $str12=substr($content1,$value1,$value2-$value1); $str12=~s/[^\d.-]//g; #print($str12); $template-&gt;param(A12=&gt;$str12); #3------------------------------------------------------ # FOR INCALL # #------------------------------------------------------- $count13=0; while ($content1 =~ m/bgcolor='green'/g) {$count13=$count13+1;} $count13=$count13-1; #print($count13); $template-&gt;param(A13=&gt;$count13); #4------------------------------------------------------ # FOR OBD # #------------------------------------------------------- $count14=0; while ($content1 =~ m/bgcolor='blue'/g) {$count14=$count14+1;} $count14=$count14-1; #print($count14); $template-&gt;param(A14=&gt;$count14); #5------------------------------------------------------ # FOR BUSY CIRCUIT # #------------------------------------------------------- $value1=0; $value2=0; if ($content1 =~ m/Busy Cir./g) {$value1=pos($content1);} if ($content1=~m/OBD/g) {$value2=pos($content1);} $str15=substr($content1,$value1,$value2-$value1); $str15=~s/[^\d.-]//g; #print($str15); $template-&gt;param(A15=&gt;$str15); #6------------------------------------------------------ # FOR THE DISPALY OF LOCAL TIME #------------------------------------------------------- $content1 = get($URL1); $value1=0; $value2=0; if ($content1=~m/Current time/g) {$value1=pos($content1);} if ($content1=~m/Circuits/g) {$value2=pos($content1);} $str16=substr($content1,$value1,$value2-$value1); $str16=~s/[^\d..:._.-]//g; #print($str16); $template-&gt;param(TIME=&gt;$str16); #2===================================================== #------------------------------------------------------ #Fetching AIRTEL HVP2 #------------------------------------------------------ my $URL2= "http://****/server2"; my $content2 = get($URL2); my $str22; my $count23; my $count24; my $str25; #2----------------------------------------------------- # FOR IP # #------------------------------------------------------ $value1=0; $value2=0; if ($content2 =~ m/IP/g) {$value1=pos($content2);} if ($content2=~m/Blocked/g) {$value2=pos($content2);} $str22=substr($content2,$value1,$value2-$value1); $str22=~s/[^\d.-]//g; #print($str22); $template-&gt;param(A22=&gt;$str22); #3----------------------------------------------------- # FOR INCALL # #------------------------------------------------------ $count23=0; while ($content2 =~ m/bgcolor='green'/g) {$count23=$count23+1;} $count23=$count23-1; #print($count23); $template-&gt;param(A23=&gt;$count23); #4----------------------------------------------------- # FOR OBD # #------------------------------------------------------ $count24=0; while ($content2 =~ m/bgcolor='blue'/g) {$count24=$count24+1;} $count24=$count24-1; #print($count24); $template-&gt;param(A24=&gt;$count24); #5---------------------------------------------------- # FOR BUSY CIRCUIT # #----------------------------------------------------- $value1=0; $value2=0; if ($content2 =~ m/Busy Cir./g) {$value1=pos($content2);} if ($content2=~m/OBD/g) {$value2=pos($content2);} $str25=substr($content2,$value1,$value2-$value1); $str25=~s/[^\d.-]//g; #print($str25); $template-&gt;param(A25=&gt;$str25); #==================================================== print $template-&gt;output; #==================================================== </code></pre> <ol> <li><p>HTML Code (.tmpl file consisting of the table and div ids):</p> <p> HVP Usage Report </p> <pre><code> &lt;font color=#00124B&gt; &lt;center&gt; &lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;Ghana &lt;img src="/ghanaa.jpg" width="80" height="40"&gt;&lt;/b&gt;&lt;/font&gt; &lt;br&gt; &lt;font size="6" face="calibri" color = #0033CC&gt;&lt;b&gt;&lt;TMPL_VAR NAME=TIME&gt;&lt;/b&gt;&lt;/font&gt; &lt;br&gt;&lt;br&gt; &lt;table border="2" cellpadding="6" cellspacing ="4" &gt; &lt;tr bgcolor=#00248E&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;Client&lt;/font&gt;&lt;/th&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;HVP&lt;/font&gt;&lt;/th&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;IP&lt;/font&gt;&lt;/th&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;Incall&lt;/font&gt;&lt;/th&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;OBD&lt;/font&gt;&lt;/th&gt; &lt;th&gt;&lt;font face="calibri" size="7" color=#BFCFFE&gt;Busy Cir.&lt;/font&gt;&lt;/th&gt;&lt;/font&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align ="center"&gt;&lt;font size="6" face="calibri" color=#00124B&gt;&lt;img src="/airtel.jpg" width="100" height="56"&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#BFCFFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;VP1&lt;/font&gt;&lt;/td&gt; &lt;td ialign ="center" bgcolor=#BFCFFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;TMPL_VAR NAME=A12&gt;&lt;/font&gt;&lt;/td&gt; &lt;div id="A1"&gt; &lt;td align ="center" bgcolor=#BFCFFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;TMPL_VAR NAME=A13&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#BFCFFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;TMPL_VAR NAME=A14&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#BFCFFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;TMPL_VAR NAME=A15&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;/div&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align ="center"&gt;&lt;font size="6" face="calibri" color=#00124B&gt;&lt;img src="/airtel.jpg" width="100" height="56"&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#809FFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;VP2&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#809FFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;tmpl_var name=A22&gt;&lt;/font&gt;&lt;/td&gt; &lt;div id="A2"&gt; &lt;td align ="center" bgcolor=#809FFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;tmpl_var name=A23&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#809FFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;tmpl_var name=A24&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;td align ="center" bgcolor=#809FFE&gt;&lt;font size="7" face="calibri" color=#00124B&gt;&lt;b&gt;&lt;tmpl_var name=A25&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt; &lt;/div&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/center&gt; &lt;/font&gt; </code></pre> <p> </p></li> </ol> <p>Please assist me applying ajax and its function on the above files. Thank You</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload