PDA

View Full Version : [Solved] Ajax timestamp to disable caching breaks URL



jfanaian
3 Aug 2007, 1:58 PM
I am trying to create a data grid using a JsonStore object using an app written in CodeIgniter but a timestamp is added at the end of the url in the format ?_dc=11.... and breaks the URLs that should be in the format that use /param/param/param.

Here is my current code:


var productStore = new Ext.data.JsonStore({
url: "<?=site_url('admin/product/get/json/') ?>",
fields: ['id', 'name'],
ciRules: true
});

var productColumns = new Ext.grid.ColumnModel([
{header: "Id", width: 120, dataIndex: "Id"},
{header: "Name", width: 120, dataIndex: "Name"}
]);

var productGrid = new Ext.grid.Grid('product-grid', {
ds: productStore,
cm: productColumns
});

productGrid.render();
productStore.load();
The current code sends the request but it returns a 404 error. How can I modify the way the timestamp is added? It would work if the request ended in /timestamp instead of ?_dc=timestamp. Is there a way to change this?

Thanks

jay@moduscreate.com
3 Aug 2007, 4:10 PM
so you're doing an SEO type of form submission right? You'll probably have to override the way the connection.js performs it's urlencode function.

trbs
3 Aug 2007, 5:34 PM
you can add disableCaching to your store's params to disable the cache-buster param in the url.

something like: (top of the head; havn't tried this)



productGrid.render();
productStore.load({params: { disableCaching: true } });


or even better:


productStore.baseParams['disableCaching'] = true;
productGrid.render();
productStore.load();

jfanaian
6 Aug 2007, 9:02 AM
so you're doing an SEO type of form submission right? You'll probably have to override the way the connection.js performs it's urlencode function.

Yeah pretty much.


you can add disableCaching to your store's params to disable the cache-buster param in the url.

Let me try that! I'll just add my own caching on the URL parameter so that it doesn't cache.

jfanaian
6 Aug 2007, 9:09 AM
Adding disableCaching did it! Thank you so much :)

trbs
7 Aug 2007, 6:52 AM
Adding disableCaching did it! Thank you so much :)

cool :)

could you add [SOLVED] to the title of this topic ? thanks.
have fun with Extjs :)