SharkBait Posted December 28, 2006 Share Posted December 28, 2006 Ok I followed the tutorial on the aJaxFreaks with updating live content or somehting (this one? http://www.ajaxfreaks.com/tutorials/2/0.php)Anyway I have my code updating on Firefox, but IE doesn't seem to want to update. Unless I close the browser and open the browser.... even with a shift-refresh it doesn't want to update.This is my ajaxFuncs.js file:[code]function createRequestObject() { var req; if (window.XMLHttpRequest) { // Firefox, Safari, Opera req = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // Cannot create object alert("There was a problem creating the XMLHttpRequest object"); } return req;}var http = createRequestObject();function sendRequest(act) { // Open PHP script for requests http.open('get', 'show_daily_count.php'); http.onreadystatechange = handleResponse; http.send(null);}function handleResponse() { if (http.readyState == 4 && http.status == 200) { // Text returned FROM PHP script var response = 0; var response = http.responseText; if (response) { // UPDATE content document.getElementById("counterTable").innerHTML = response; // Refresh every 10 secs setTimeout(counterTable, 1000); } } }function counterTable() { sendRequest('counterTable');}[/code]I call the counterTable() function on the body's onload(). the show_daily_count.php just echo's a table that has been filled by MySQL data.Is there something special I need to do to my headers for IE to get this to work? Not have it read from the cache or something? Quote Link to comment Share on other sites More sharing options...
ober Posted December 31, 2006 Share Posted December 31, 2006 Are you sure the object is being created? Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 2, 2007 Author Share Posted January 2, 2007 I load it on my header.html page in the <body onload="javascript:counterTable();">Or is that incorrect? Quote Link to comment Share on other sites More sharing options...
ober Posted January 3, 2007 Share Posted January 3, 2007 I don't understand why you would call an AJAX script on the onload event. THAT DEFEATS THE PURPOSE OF USING AJAX! Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 3, 2007 Author Share Posted January 3, 2007 That is what someone told me to do :PI'm not sure where I put the bit of code then.I'm trying to update a table query on the fly so the user doesn't have to refresh the page. No need to click a button or anything just have the page do it. Quote Link to comment Share on other sites More sharing options...
ober Posted January 3, 2007 Share Posted January 3, 2007 Oh... well, I guess it makes sense... I wasn't clear on what you were doing with it.Are you getting any errors in IE? Or is it just not working? Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 3, 2007 Author Share Posted January 3, 2007 IE gives me nothing in the way of errors. It doesn't seem to refresh like Firefox does. You can highlight the text in firefox and it removes the highlight when it refreshes.IE just stands and acts dumb :) Could it be a caching issue with IE? When I manuall update the page is doesn't update the table either....if that helps at all Quote Link to comment Share on other sites More sharing options...
ober Posted January 3, 2007 Share Posted January 3, 2007 IE->Tools->Internet Options->Temp Internet Files (first tab)-> Settings...What is the first question/option set to?Do you have a live version we can look at? Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 3, 2007 Author Share Posted January 3, 2007 Check for newer version of stored pages: Automatically.Unforturnately its on an intranet so you won't be able to see it. Quote Link to comment Share on other sites More sharing options...
ober Posted January 4, 2007 Share Posted January 4, 2007 Change it to "every time" and see if that helps. Quote Link to comment Share on other sites More sharing options...
irken Posted January 4, 2007 Share Posted January 4, 2007 Hello.I've had this problem alot when working with AJAX in IE and updating contents from databases. I usually just fix it by putting a non-cache header in my PHP script, like below:[code]header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");[/code]On MSDN it also says:[quote]Microsoft Internet Explorer caches the results of HTTP GET requests in the Temporary Internet Files (TIF) folder. In most cases, caching improves performance for data that will not change frequently. To guarantee that the results are not cached, use POST.[/quote]..[code]// Refresh every 10 secssetTimeout(counterTable, 1000);[/code]is one second tho :D.[quote]iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])[/quote] Quote Link to comment Share on other sites More sharing options...
ober Posted January 4, 2007 Share Posted January 4, 2007 ... another reason to use POST instead of GET in your AJAX calls. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 4, 2007 Author Share Posted January 4, 2007 It seems to be working now and I didn't do anything with it.So I am not sure why it's working now.Thanks though. I'll have to look more into POST, it's set up a bit differently correct? Quote Link to comment Share on other sites More sharing options...
ober Posted January 4, 2007 Share Posted January 4, 2007 Just slightly... the change is extremely minor. I've always used POST because POST can handle more data. 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.