JQuery, AJAX and IE
On our FlipIT service web page, we experienced an interesting problem. There is a “Did you know” (DYK) section that refreshes upon clicking the link. Behind all that is an AJAX created with JQuery $.get method. All normal thus far.
Until IE steps into the picture. I don’t know if the same behaviour is in IE 8 as well, but IE 7 definitely has issues with AJAX requests. If URL of request doesn’t change, IE caches the result and passes it back to you. This wouldn’t be a problem if you would actually expect to see the same result each and every time. However, in our case, where it is desired that DYK section is not always the same, this is kind of annoying.
To sort out our issues, we just added a random number to the request. This number is changed to new random value each and every time the request is processed.
October 28th, 2009 at 15:16
Yes – ie has problems with caching urls in ajax requests – and as you mention it is not just a jQuery thing it is AJAX in general. Our workaround was the same either compute the random part using computed text in a url or using a javascript “random” type function.
You guys doing a lot of jQuery stuff? I am thinking about blogging some jQuery examples and perhaps even giving away a free application that runs on standard Domino with jQuery. People could use this to take code out of or use the actual application itself.
October 29th, 2009 at 09:03
I thought it is not only jQuery issue. However, I was too short on time and too lazy to try it out using regular HTTPRequest.
As far as jQuery goes. We are using it. Not extensively, but whenever I have to do something a bit more complex and I just cannot be fooled into playing with all that cross-browser compatibilities, I use jQuery.
On http://www.nil.com/ipcorner, I created a dynamic sectioning of the article. If you click on view article, you will see chapters in left sidebar, that is generated with JavaScript and jQuery. Latest article: http://www.nil.com/ipcorner/CiscoTP/