Httppost之后的Javascript函数


Javascript function after Http post

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

file1.php:

<?php
if (isset($_REQUEST['feed_me'])): 
    echo '<script>alert("TEST !!!");</script>';
endif;
?>
<iframe width="100%" height="300" src="file2.php"></iframe>

file2.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)中

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

我认为Iframe不适用于parent window

更换线路

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

通过

include_once("file2.php");

以上内容将适用于您。