![]() |
AJAX function only works once!
Hello! I have written this test code:
Code:
<html>Code:
<?php |
I think (but if i'm thinking wrong, correct me) that IE caches the result, so it's always the same.
this is a classical problem, that can be avoided by passing a random useless parameter, or a datetime, so that IE thinks that you're requesting something new, and it avoids to cache the result. |
Quote:
|
When I use Firefox, I press ctrl+f5 to reload all the page without using the version cached. I think you can try the same on IE
this can be a solution for you, but not for the people who'll see your end application.. but i don't know any other answer, sorry :) |
I've got the exact same problem in IE, except adding a random number to the url isnt helping, any ideas?
Code:
var xmlHttp |
Quote:
Just taking a shot, try adding a counter instead as I did, there could be a chans that helps. |
I tried a counter and still no luck. And yes I checked that the counter was being incremented
|
Quote:
|
Using POST would clear it up since GET is supposed to cache.
you could also do xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); Eric |
tried both the header and the post method - still no luck, it still only works the first time in IE
|
Are you reusing the Object?
The correct order with IE is open() onreadystatechange send() If you have onreadystatechange before the open, IE will not work. Eric |
You're only setting the xmlHttp variables once. Try creating it everytime changeField function is called.
|
alien51 had it - it was the ordering of open onreadystatechange and send, that'll teach me to grab code from w3schools rather than walking up to my pc and getting my own ;)
|
A bunch of people complain about that issue with the W3Schools code. A bunch of pople have sent them emails telling them to change it, but they never did.
Eric |
Thanks Alien51
Thanks Alien51. You just saved me.
|
| All times are GMT +1. The time now is 04:47 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.