How do I fully refresh the page in CodeIgniter?
Solution 1
Unfortunately, using header
to refresh/redirect will only reflect the changes in the container that is displaying the PHP page.
To refresh the parent page (i.e. the page that is displaying the overlay itself), you will need to do it on the client-side using Javascript. These questions should help you get on the right path:
- Redirect parent window from an iframe action
- PHP "header (location)" inside IFRAME, to load in _top location?
Solution 2
You can use this code to refresh in codeigniter:
redirect($_SERVER['REQUEST_URI'], 'refresh');
it should work!
Solution 3
This one is more simple
redirect($this->uri->uri_string());
Solution 4
You can use this code to refresh in codeigniter:
redirect($_SERVER['REQUEST_URI'], 'refresh');
Hope this helps.
Evernoob
Web developer. I mainly like working in front-end: HTML, CSS, Javascript. Also use a lot of PHP, CodeIgniter, MySQL and Doctrine2.
Updated on November 19, 2020Comments
-
Evernoob over 3 years
I am loading a form in an overlay. The overlay has a separate controller and action to the page that invokes the overlay.
On form submit, if successful, I simply want to reload the referring page that the overlay was loaded from. I can get the referring page to load, but it places the content inside the overlay.
header("Location: www.example.com", true, 302);
does not work.
Using the URL helper like this:
$url = $_SERVER['HTTP_REFERER']; redirect($url);
Also does not work. Every time it loads in the overlay. I am sad because of it.
-
user3219020 over 10 yearsYou can change $_SERVER['REQUEST_URI'] to whatever you url you wanted.
-
heySushil about 5 yearsIt works, but what if I want to go on a particular function with a flash message just with a refresh. It's confusing here. My problem is link . @jasmeen , Philip G and Deepti
-
Habib Rehman almost 5 yearswhat if there are params in uri?
-
Habib Rehman almost 5 yearsthis is jquery not php
-
FraggaMuffin over 4 yearsmore details in: stackoverflow.com/questions/723883/redirect-with-codeigniter
-
Lajos Mészáros about 3 yearsthis is vanilla javascript, not jquery