php 如何在 CodeIgniter 中完全刷新页面?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12863349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I fully refresh the page in CodeIgniter?
提问by Evernoob
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 助手:
$url = $_SERVER['HTTP_REFERER'];
redirect($url);
Also does not work. Every time it loads in the overlay. I am sad because of it.
也不起作用。每次它加载到覆盖层中。我因此而难过。
采纳答案by Aamir
Unfortunately, using headerto refresh/redirect will only reflect the changes in the container that is displaying the PHP page.
不幸的是,使用header刷新/重定向只会反映显示 PHP 页面的容器中的更改。
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:
要刷新父页面(即显示覆盖层本身的页面),您需要使用 Javascript 在客户端执行此操作。这些问题应该可以帮助您走上正确的道路:
回答by Deepti Gehlot
You can use this code to refresh in codeigniter:
您可以使用此代码在 codeigniter 中刷新:
redirect($_SERVER['REQUEST_URI'], 'refresh');
it should work!
它应该工作!
回答by Jasmeen
This one is more simple
这个更简单
redirect($this->uri->uri_string());
重定向($this->uri->uri_string());
回答by user3219020
You can use this code to refresh in codeigniter:
您可以使用此代码在 codeigniter 中刷新:
redirect($_SERVER['REQUEST_URI'], 'refresh');
Hope this helps.
希望这可以帮助。
回答by user3219020
You do not have to supply additional two arguments for header. Just use this pattern:
您不必为 提供额外的两个参数header。只需使用此模式:
header('Location: www.somewhere.com');
Also, check out this article about a similar matter:
另外,查看这篇关于类似问题的文章:
回答by maqs
redirect(site_url(strtolower(__CLASS__)));
回答by Pierre Alexandre
It's just
只是
redirect('/some_url', 'refresh');
回答by user2079277
This one is more simple for everone :) location.reload()
这个对everone来说更简单:) location.reload()

