0

我想在 POST isset 时创建触发器,但来自不同的文件。

文件1.php:

<?php
if (isset($_REQUEST['feed_me'])): 
    echo '<script>alert("TEST !!!");</script>';
endif;
?>

<iframe width="100%" height="300" src="file2.php"></iframe>

文件2.php:

<?php
if (isset($_POST['feed_me'])):

    $url = 'file1.php';
    $fields = array(
        'feed_me' => 1
    );
    foreach($fields as $key=>$value) {$fields_string .= $key .'='.$value.'&';}
    $fields_string = rtrim($fields_string,'&');
    $feed_post = curlPOST($url, $fields, $fields_string);
    //var_dump($feed_post);

endif;
?>

<form method="post" action="">
  <button type="submit" name="feed_me">Feed Me !!!</button>
</form>

如上面的代码,当我点击 file2.php 上的提交时,响应 javascript 警报应该出现在 file1.php 中(其中有 iframe 到 file2.php)

你能帮我解决这个问题吗?

4

1 回答 1

0

我认为,Iframe不会为parent window

换行

<iframe width="100%" height="300" src="file2.php"></iframe>

经过

include_once("file2.php");

以上将为您工作。

于 2013-07-05T07:29:01.810 回答