How do I fully refresh the page in CodeIgniter?

67,362

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:

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.

Share:
67,362
Evernoob
Author by

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, 2020

Comments

  • Evernoob
    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
    user3219020 over 10 years
    You can change $_SERVER['REQUEST_URI'] to whatever you url you wanted.
  • heySushil
    heySushil about 5 years
    It 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
    Habib Rehman almost 5 years
    what if there are params in uri?
  • Habib Rehman
    Habib Rehman almost 5 years
    this is jquery not php
  • FraggaMuffin
    FraggaMuffin over 4 years
  • Lajos Mészáros
    Lajos Mészáros about 3 years
    this is vanilla javascript, not jquery