I have a really odd problem. I have a script that works in Firefox but doesn't in IE. There are no errors in firebug.
All it does is make a request to a page to see if there are any new items, if the value is greater than the one stored then it makes a new request for the content. I am running out of ideas on what I can do to make this work in IE.
Thank You!
David
All it does is make a request to a page to see if there are any new items, if the value is greater than the one stored then it makes a new request for the content. I am running out of ideas on what I can do to make this work in IE.
Thank You!
David
Code:
var whiteboard_total = 0;
function makeRequest(url) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function() { checkTotal(http_request); };
http_request.open('GET', url, true);
http_request.send("");
}
function checkTotal(http_request) {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if (whiteboard_total >= 0) {
temp_total = parseInt(http_request.responseText);
if (temp_total > whiteboard_total) {
whiteboard_total = temp_total;
var random_num = (Math.round((Math.random()*1000)+1))
var url = "whiteboard_output.asp?division=[%division%]&random=" + random_num
getContent(url);
}else{
whiteboard_total = temp_total;
}
}
setTimeout("makeRequest('whiteboard_total.asp?division=[%division%]')", 5000);
} else {
alert('There was a problem with the request.');
}
}
}
function getContent(url) {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
http_request.onreadystatechange = function() { updateContents(http_request); };
http_request.open('GET', url, true);
http_request.send(null);
}
function updateContents(http_request) {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById("content").innerHTML = http_request.responseText;
self.focus();
} else {
alert('There was a problem with the request.');
}
}
}
window.onload = function() { makeRequest('whiteboard_total.asp?division=[%division%]'); };