Forum Moderators: open

Message Too Old, No Replies

Ajax problem with IE?

         

txbakers

12:13 am on Aug 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a strange problem coming up. I have a simple Ajax screen where the user checks a checkbox and it updates the database. then, after the database is updated, it queries and is supposed to display an appropriate message.

On my test machines (IE7) it works perfectly every time.

On my clients Safari (MAC) it works perfectly.

On her IE7 and IE6 on various machines, it is not working correctly - she has cleared cache, forced refresh, and still the browser hangs on to the old.

What would cause IE to hang on to the old data and not run the Ajax?

she has also adjusted the Cache to pull a new page every time.

I'm stumped and so is she.

Thanks.

DrDoc

7:51 pm on Aug 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It depends on which MSXML version is used. Make sure you do something similar to this (in the same order as indicated):
var xmlHttp; 
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}

txbakers

8:05 pm on Aug 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Doc, that's what I have, except my first line sets xmlHttp = null;

should that matter?

Thanks.

DrDoc

12:40 am on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, that shouldn't matter.

Are the security settings different on your client's machine? Anything else different between the two?

penders

12:37 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have had problems with IE's caching behaviour in the past... having to resort to appending timestamps on the XMLHttpRequest to get around the issue.

txbakers

4:45 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



timestamps sounds cool. How does that work, can you post a code sample?

DrDoc

6:13 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



var uri = "http://www.example.com/foo/";
var now = new Date();
var uts = now.getTime();
uri = uri + "?" + uts;

txbakers

9:35 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok so just add that as a parameter, easy enough. But does it help with the Ajax running in the background?

DrDoc

10:31 pm on Aug 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If each request adds the Unix timestamp as a parameter, yes. That should address the caching problem (assuming that's what's causing you trouble).