I want to transition and reload the parent frame by submitting the form in iframe.

Asked 2 years ago, Updated 2 years ago, 51 views

If you POST on a page inside an inline frame, you do not know how to reload the entire parent page.

Development Environment PHP 5.2.8
CakePHP 2.6.2
Enter a description of the image here

In the above picture, /××××/sample is displayed in iframe on the main page /×××××/sample.
①If you set the name in the name text box and press OK, it will be updated to DB.
Only the pages in iframe transition and the main page is not reloaded.
After POSTing this on page /xxx/sample in iframe
Is there a way to transition the entire page to /×××/main or reload the entire page after updating?
Thank you.
Below is an excerpt of the code.

main.ctp

-----------------------------------------------------------
<?phpecho$this->Form->create('xxx');?>
<?php echo$this->Form->input('id',array('type'=>'hidden'));?>
<iframe src="/xxx/sample" height="300">/iframe>
* Displays the updated name in iframe.
------------------------------------------------------

sample.ctp

-----------------------------------------------------------
<?phpecho$this->Form->create('xxx');?>
<?php echo$this->Form->input('id',array('type'=>'hidden'));?>
<?phpecho$this->Form->input('name',array('size'=>'15','label'=>false));?>
<?phpecho$this->Form->submit('OK',array('div'=>false));?>
------------------------------------------------------

sample.php

-----------------------------------------------------------
if($this->xx->save($this->data)){
    $this->redirect(array('action'=>'main'));
} else {
    $this->redirect(array('action'=>'logout'));
}
------------------------------------------------------

php html cakephp

2022-09-30 16:12

2 Answers

We responded by specifying a target in the form as shown below.

<?phpecho$this->Form->create('xxx',array('target'=>'_top'));?>


2022-09-30 16:12

I don't think the cakephp side can solve this problem, so why don't you pick up the event in iframe on the front side (Javascript, etc.) and reload the parent page?
For your information, I will attach a URL such as how to detect iframe events in Jquery.
http://zxcvbnmnbvcxz.com/jquery-iframe-loaded/


2022-09-30 16:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.