Hey everyone,
In developing my Module, I have forms submitted with AJAX requests and when the result is loaded it seems the output is cached. If the page is refreshed everything is updated. I know CI had this problem and the solution I found then was to not cache the page with the following code
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
$this->output->set_header("Pragma: no-cache");
but that doesn't seem to work, is there a different way to achieve this?
Thanks in advance.
-Justin
Comments
I've had no problems with CI and Ajax in the past.
Are you returning JSON and pushing to the DOM or?
I'm building forms in a controller that are outputted to a view. There are 3 forms that show up when the previous one has been submitted. When the form is submitted the controller is reloaded with the same view it's just creating the form after each request. So the whole page is returned and I just update the div that holds the forms. To see how it works with just CI you can go here:
https://www.gmvoices.com/asteriskstore/order
I'm trying to recreate this whole store as a module in the CMS. Everything works right when I don't use AJAX and if I refresh the page, it is updated.
-Justin
http://api.jquery.com/jQuery.ajax/
Also, appending a random string or timestamp on the request as a query string param should create a unique request to prevent caching.
Hmm... I'm not sure. Anyone else have any ideas?
If something is posted it's saved in the user's session and I was checking the session before i was setting it. so as a result i was always getting the previous posted info. It's working perfectly now, man I feel pretty dumb. Thanks though.
-Justin