everettcomstock Posted April 5, 2007 Share Posted April 5, 2007 Hi Guys, I should probably be able to figure this one out, but for some reason it is really kickin' my ass. I have a div (rightSection), that I want to reload every 60 seconds. I do not want to reload the entire page because I have some embedded video clips that will stop playing if an entire page load is started. I know the name of the div, the name will not change and does not need to be dynamic. The source code that I want to load into the div I have separated into another PHP file so that the proper image headers will be returned. This file will also never change. But for some reason, I cannot seem to write a javascript / ajax function that will simply reload "right.php" into "rightSection" div. Here is what I have put together. I personally think it is way to much code for what I am trying to do. function refresh() { // Reload the page every 60 seconds function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('Problem creating the XMLHttpRequest object'); } return req; } // The Target DIV is labeled rightSection function handleDivTag(rightSection) { var divtag; return divtag; } // Make the XMLHttpRequest object var http = createRequestObject(); // Create the Divtag Handler -- Mainly an IE 6 Fix var divhandler = new handleDivTag(null); function sendRequest(rightSection) { // Open PHP script right.php for requests http.open('get', 'right.php'); http.onreadystatechange = handleResponse; divhandler.divtag = divtag; http.send(null); } function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM the PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById(divhandler.divtag).innerHTML = response; } } } setTimeout("refresh();",60000); Any help or direction with this issue would be greatly appreciated. Thank you, Everett } Quote Link to comment Share on other sites More sharing options...
everettcomstock Posted April 7, 2007 Author Share Posted April 7, 2007 Hi everybody, I solved my issue in the previous post, however now, I am facing a new issue. This script work in Firefox and Opera, but does not work in IE 6 or IE 7. Can anyone see any obvious problems with my code that would keep it from running in IE? Code : function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('Problem creating the XMLHttpRequest object'); } return req; } // The Target DIV is labeled rightSection function handleDivTag(divtag) { var divtag; return divtag; } // Make the XMLHttpRequest object var http = createRequestObject(); // Create the Divtag Handler -- Mainly an IE 6 Fix var divhandler = new handleDivTag(null); function sendRequest(divtag) { // Open PHP script right.php for requests http.open('get', 'right.php'); http.onreadystatechange = handleResponse; divhandler.divtag = divtag; http.send(null); } function handleResponse() { if(http.readyState == 4 && http.status == 200){ // Text returned FROM the PHP script var response = http.responseText; if(response) { // UPDATE ajaxTest content document.getElementById(divhandler.divtag).innerHTML = response; } } } Thanks again for your time. Everett Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.