Following up on what huck suggested, here is a demo to play with using Ajax. Change the file paths and urls to suit your web server.
An html page

<html> <head><title>Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jque +ry.min.js"> </script> <script> $(document).ready(function() { $(".update").click(function(){ var button = this; $.ajax({ type: 'POST', url: 'runme.cgi', data: { 'action': $(button).attr("id") }, success: function(res) { alert( res.msg ); var myIFrame = document.getElementById("dataDialog"); myIFrame.src = "runme.cgi?action=result"; }, error: function() { alert("Error : did not work"); } }); }) }) </script> </head> <body> <iframe id="dataDialog" src="about:blank"></iframe> <h2>Using Ajax</h2> <button class="update" id="update_1">Update 1</button> <button class="update" id="update_2">Update 2</button> <button class="update" id="update_3">Update 3</button> <button class="update" id="update_4">Update 4</button> </body> </html>

and the script runme.cgi

#!/usr/bin/perl use CGI; use JSON; use strict; my $logtext; my $logfile = 'c:/temp/web/update.log'; # somewhere writeable my $q = new CGI; my $action = $q->param('action'); if ($action =~ /update/){ # do stuff to update database sleep 1; open OUT,'>', $logfile or die "$!"; print OUT "Result of $action on\n".scalar(localtime)."\n"; print OUT "Line $_ message\n" for (1..rand(10)); close OUT; my $json = encode_json( { msg => "$action done" } ); # response print $q->header( -type => 'application/json' ),$json; exit; } if ($action eq "result"){ # get results of last update if (-e $logfile){ open IN,'<', $logfile or die "$!"; $logtext = do {local $/;<IN>}; close IN; } print $q->header( {-pragma =>'no-cache', -cache_control => "no-store,no-cache,must-revalidate"} ), $q->start_html, $q->pre($logtext),$q->end_html; exit; }
poj

In reply to Re^5: send windowmessage from cgi back to form that called the cgi by poj
in thread send windowmessage from cgi back to form that called the cgi by tultalk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.