How do I fully refresh the page in CodeIgniter?

我的未来我决定 提交于 2020-04-15 07:22:06

问题


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.


回答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?



回答2:


You can use this code to refresh in codeigniter:

redirect($_SERVER['REQUEST_URI'], 'refresh'); 

it should work!




回答3:


This one is more simple

redirect($this->uri->uri_string());




回答4:


You can use this code to refresh in codeigniter:

redirect($_SERVER['REQUEST_URI'], 'refresh'); 

Hope this helps.




回答5:


You do not have to supply additional two arguments for header. Just use this pattern:

header('Location: www.somewhere.com');

Also, check out this article about a similar matter:

Redirect with CodeIgniter




回答6:


redirect(site_url(strtolower(__CLASS__)));



回答7:


It's just

redirect('/some_url', 'refresh');



回答8:


This one is more simple for everone :) location.reload()



来源:https://stackoverflow.com/questions/12863349/how-do-i-fully-refresh-the-page-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!