by tbullard1 on Sun Apr 22, 2007 3:29 am
Thanks Mike - Below is the actual js I'm running: I call the script like this
<div class="click" onclick="setupRtvJobList('rtvactjob.php','Job_Status','joblist',1)"> Start Rtv Job Status</div>
The fetchdata in the RtvJobList function runs. and the setTimeout apparently runs because firebug (which I installed - thanks) gives me an error at the end of the time out function that says url is not defined though the fetchdata function used it properly
I'm probably going about this all the wrong way anyway - basically I'm just trying to rtv a set of joblog info every X amt of time and using an ajax call - write a new div element.
The type of joblog info rtv is conditioned by a select dropdown. Sorry for being so dense but I'm claiming newbie status!
<script type="text/javascript">
var theDelay = 5500;
var state = null;
var object = null;
var toRepeat = 0;
function setupRtvJobList(url,datatoSend,objectID,onOffon) {
alert(onOffon);
if (onOffon == 1) {
toRepeat = 1;
RtvJobList(url,datatoSend,objectID);
}
else toRepeat = 0;
}
function RtvJobList(url,datatoSend,objectID) {
if (toRepeat == 1) {
fetchData(url,datatoSend,objectID);
setTimeout("RtvJobList(url,datatoSend,objectID)",theDelay)
}
else{
return;
}
}
function fetchData(url,datatoSend,objectID){
var pageRequest = false
if (window.XMLHttpRequest) {
pageRequest = new XMLHttpRequest()
}
else if (window.ActiveXObject){
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e) {
try{
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else return false
pageRequest.onreadystatechange=function() {
filterData(pageRequest,objectID)
}
var o = document.getElementById(datatoSend);
var sendData = 'sendData=' + o.options[o.selectedIndex].value;
pageRequest.open('POST',url,true);
pageRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
pageRequest.send(sendData);
}
function filterData(pageRequest,objectID){
if (pageRequest.readyState == 4) {
if (pageRequest.status==200)
var object = document.getElementById(objectID);
var d = document.createElement("DIV");
d.innerHTML = pageRequest.responseText;
object.appendChild(d);
}
}
</script>