最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PHP refresh parent window after closing a child window - Stack Overflow

programmeradmin0浏览0评论

I have 3 php files: view.php, edit.php and edit2.php.

view.php is where I view the content of my database. I use edit.php to enter new data and it's a small window that in which I type in a content I want to include in my db.
Then, I pass all of the data to edit2.php which doesn't display anything but only has implemented MySQL queries.

Now I would like to have something like this:

I'm on view.php. I click a button, edit.php opens as a new, small window. I enter the data, click SUBMIT button, everything is sent to edit2.php but at the same time the window is closed and view.php is refreshed.

I would be thankful if you could help. Thanks in advance.

I have 3 php files: view.php, edit.php and edit2.php.

view.php is where I view the content of my database. I use edit.php to enter new data and it's a small window that in which I type in a content I want to include in my db.
Then, I pass all of the data to edit2.php which doesn't display anything but only has implemented MySQL queries.

Now I would like to have something like this:

I'm on view.php. I click a button, edit.php opens as a new, small window. I enter the data, click SUBMIT button, everything is sent to edit2.php but at the same time the window is closed and view.php is refreshed.

I would be thankful if you could help. Thanks in advance.

Share Improve this question edited Jul 28, 2014 at 9:21 whiteestee asked Jul 28, 2014 at 9:08 whiteesteewhiteestee 3011 gold badge4 silver badges12 bronze badges 3
  • how r you saving the data?? with ajax?? – Sougata Bose Commented Jul 28, 2014 at 9:13
  • I use html post method and I send it to mysql query – whiteestee Commented Jul 28, 2014 at 9:14
  • if you are doing this all on server side the user header function of php.else use window.opener.location.reload() after saving data via ajax – Sougata Bose Commented Jul 28, 2014 at 9:22
Add a ment  | 

3 Answers 3

Reset to default 4

You can use the js function window.opener.location.reload().There is no need of ajax for refreshing the page..Simple js is enough.

You may use header('Location: view.php'); at the end of your edit2.php

Add following code to your edit.php

    <script>
    window.onunload = refreshParent;
    function refreshParent() {
        window.opener.location.reload();
    }
   </script>
发布评论

评论列表(0)

  1. 暂无评论