Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax scrolling message banner

Status
Not open for further replies.
Aug 18, 2003
111
0
0
GB
Hi,

I have a page which uses ajax to get info from a database and display it on screen with refreshing. This worked fine. I am now trying to put this text into a scrolling message which move across the screen but it doesn't work. If anyone could tell me where I'm going wrong I would be very greatful. Code below.

<html>
<head>
<title></title>
<script type="text/javascript">

msg = "";
spacer = "";
pos = msg.length;

function loopfunc() {
setTimeout("getGallery()",3000);
setTimeout("ScrollMessage()",200);
}

function ScrollMessage() {
newtext = msg.substring(pos, msg.length) + spacer + msg.substring(0, pos);
document.getElementById("scroll").innerHTML= newtext;
pos=pos+1;
if (pos > msg.length) {
pos = 0;
}
setTimeout("ScrollMessage()",200);
}


function getGallery() {
var url = "totalstoday2.cfm?" + Math.random();
var callback = processAjaxResponse;
executeXhr(callback, url);
}

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

function processAjaxResponse() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
var answer = req.responseText;
msg = req.responseText;
setTimeout("getGallery()",3000);
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
setTimeout("getGallery()",3000);
}
}
}


</script>
</head>

<body onLoad="loopfunc()">

<table width="100%">
<tr>
<td id="scroll"></td>
</tr>
</table>

</body>
</html>
 
Does this line parse:

var callback = processAjaxResponse;



Phil Hegedusich
Senior Programmer/Analyst
IIMAK
-----------
Pity the insomniac dyslexic agnostic. He stays up all night, wondering if there really is a dog.
 
Have you tried posting to the Javascript forum? They probably have the right expertise over there.
 
Couldn't you just do a cfquery then cfoutput the values in a <marquee> tag?

Please forgive me if this is a dumb idea, I am very new to CF.
 
Oh nevermind, missed the AJAX part, and after reading what that is my sugegstion will not work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top