Category Archives: Javascript

Short note of Javascript refresher

In the program i made, which tabulates the latest 20 call in a minute, I’ve found some good resource for it.
My setup, perl-cgi script is the one that generates the list of calls. This script is just called via an Ajax function.

The main important part of that is part that contains this setInterval.
I chose setInterval since the “Call Accounting System” i made needs a refreshing every minute to update
the user about the activity of PBX.

The code also requires to have an id “content” to have the content generated by “refresher.cgi” displayed.
An example of usage will be.

<div id=”content”>&nbsp;</div>

and i put the code at the bottom of the html page.

<script type=”text/javascript” src=”20records.js”></script>

Below is the content of the 20records.js file:

var xmlhttp;

function showList()
if (xmlhttp==null)
alert (“Browser does not support HTTP Request”);
var url=”refresher.cgi”;

function stateChanged()
if (xmlhttp.readyState==4)

document.getElementById(‘content’).innerHTML = xmlhttp.responseText;

function GetXmlHttpObject()
if (window.XMLHttpRequest)
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
if (window.ActiveXObject)
// code for IE6, IE5
return new ActiveXObject(“Microsoft.XMLHTTP”);
return null;