Hi Guys,

I've been up all night with this one. I have a javascript which reads from my system whether I'm on my voip or not - something I'm proud of. I wanted to have this update a mysql database every 2 seconds so have got this so far:

<?
header("Cache-Control: post-check=1,pre-check=2");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
$time=rand(1000,100000);
?>
<SCRIPT type="text/javascript">
var CLMgr = new ActiveXObject("CLMgr.ClientLineMgr");
var oline = CLMgr.DispSelectedLine;
var warthog = oline.DispIsOutgoingCall;
var szNumber = oline.DispPeerNumber;


var hold = "../../Modules/Lab/data_feed_process.php?time=<?=$time;?>&tel=";
var page = hold + szNumber;

function ajax(url,target)
{


//native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
req.send(null);
//IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {ajaxDone
(target);};
req.open("GET", url, true);


req.send();
}
}
setTimeout("ajax(page,szNumber,oline,CLMgr,'scriptoutput')", 2000);
}
function ajaxDone(target) {
//only if req is "loaded"
if (req.readyState == 4) {
//only if "OK"
if (req.status == 200 || req.status == 304) {
results = req.responseText;

} else {
document.getElementById(target).innerHTML="ajax error:\n" +
req.statusText; } }}
</script>
<body onLoad="ajax(page,szNumber,oline,CLMgr,'scriptoutput')">
<span id="scriptoutput"></span>

Basically var page ends up carrying the phone number I'm connected to to the data_feed_process.php page which updates the database. This works great however the data actually sent doesn't actually change regardless of whether I disconnect the phone, until I press refresh. So if I make a call and load the page, every two seconds the database updates the fact that I'm on the phone.

I somehow need the variables that get the phone number to refresh at the same time javascript times out the above, as you'll see I've added the variables to the timeout and onload areas with no joy at all. Just to note unfortunatley the phone nubmer can only be gained client side ie via javascript.

If anyone can help I would really appreciate it, I need some sleep!