PDA

View Full Version : AJAX requests broken in IE



cwolves
10 Jul 2007, 7:12 PM
Ext.Ajax.request doesn't always make a request in IE. Specifically IE is, well stupid, and doesn't always send the request to the server if the URL is the same. I usually get around this by doing something like:

url: 'site.php?r='+Math.random()

I believe that this should be built into ExtJS, or something like it so that the request is actually always made and not pulled from IE's cache.

jack.slocum
10 Jul 2007, 7:35 PM
And how would this be a bug in Ext??

If you don't want caching, you can either use POST or set headers on the server to control IEs caching.

You can also globally generate a cache buster parameter using Ext.Ajax events:


Ext.Ajax.on('beforerequest', function(){
Ext.Ajax.extraParams = {'nocache': new Date().getTime()};
});

cwolves
13 Jul 2007, 8:49 AM
It's a "bug" because other frameworks handle it :-) I merged some code from my own framework and other code from prototype and this pops up.

Maybe more of a feature request? If(Browser==IE){ // prevent caching by default }

jay@moduscreate.com
13 Jul 2007, 9:01 AM
And how would this be a bug in Ext??

If you don't want caching, you can either use POST or set headers on the server to control IEs caching.

You can also globally generate a cache buster parameter using Ext.Ajax events:


Ext.Ajax.on('beforerequest', function(){
Ext.Ajax.extraParams = {'nocache': new Date().getTime()};
});

Generally folks who perform XHR's don't want caching.

jack.slocum
14 Jul 2007, 8:09 AM
There have specifically been requests for caching where caching won't work. It's bad to assume no one wants caching. Instead of making that assumption, there is a tiny snippet of code that will make it work how you want it to globally.