The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

blowfish (6) [Avatar] Offline
#1
I searched because I'm thinking this must have come up, but I cannot find it.

A few months back, I was trying to get AJAX to work and the send (request?) statement kept behaving as though it really wasn't contacting the server (other than the first time). I'm grateful for the response on this forum that suggested I add something different (e.g. a timestamp) to the send statement each time because the machine was thinking it had already handled an identical request and didn't bother to actually contact the server. IT WORKED. That appeared to be the problem.

I'm tesing with different browsers, and I just noticed that with Internet Explorer 7 (IE7) it is behaving as though the send is identical. It works with all other browsers, but not with IE7. Has anyone got any ideas ?

Thanks in advance.
Pascarello (208) [Avatar] Offline
#2
Re: IE7 problem
Something like:

xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");

Eric
blowfish (6) [Avatar] Offline
#3
Re: IE7 problem
Eric,
thanks. I'm really new at this and quite ignorant. Where would I put that statement in this code?


if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
d = new Date();
t = d.getTime();
thetimestring=t.toString(10);
req.send(thetimestring);
}

Thanks again.
Pascarello (208) [Avatar] Offline
#4
Re: IE7 problem
change xmlhttp to req and stick it anywhere after the open() method. You can get rid of the timestamp stuff also

Eric
blowfish (6) [Avatar] Offline
#5
Re: IE7 problem
Eric,
this is what I am using now

if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.setRequestHeader("If-Modified-Since","Sat, 01 Jan 2000 00:00:00 GMT");
req.send();
}

And it fails to work at all.

Have you got a piece of code that works? I would be pleased to retrofit it into mine.

Thanks again for all your time.

Message was edited by:
blowfish
blowfish (6) [Avatar] Offline
#6
Re: IE7 problem
YO!

I just put the datestamp back into the send (because I saw firefox tell me in javascript console that I was short on parameters, and now it works with all the browsers (at least firefox, safari, and IE7) !

here's the code right now

if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");
//req.send();
d = new Date();
t = d.getTime();
thetimestring=t.toString(10);
req.send(thetimestring);
}

Thanks very much.

Message was edited by:
blowfish
badcop666 (1) [Avatar] Offline
#7
Re: IE7 problem
Hi blowfish

first thing I think of is are you POST-ing or GET-ing ?

Remember that http is designed to cache GET's for performance, but not POST's because they represent unique once-only transactions.

Hence, your choice of request should start with this.

Yes you can use a unique-ifier in a GET to circumvent the browser cache ( random between 0 and .9999 * 99999999 for example) however, a POST is designed to be processed by the server, and not cached.

I'm not saying this is your answer, but it might be a fundmental point for you to consider.

best of luck!

Message was edited by:
badcop666