【问题标题】:Header location: load contents into a page div标头位置:将内容加载到页面 div
【发布时间】:2011-04-14 16:11:47
【问题描述】:

这是我正在构建的网站的结构:

我有 first.php,其中包括 second.php。

在 second.php 中,我有一个表单链接,并且我有 $_GET 来获取在此结构的最后一页发送的 url 参数。

form.php 告诉 action.php(这个结构的最后一页)switch case 是 FORM。 里面的表格我有:

header("Location: second.php?param1=OK&param2=OK");

通过这一行,我加载了带有参数的 second.php 页面,但我需要加载的是 first.php 页面,包括 second.php 以及参数,因此我可以使用 $_GET

有什么办法可以做到吗?结构下方。

非常感谢!

first.php

I'm the first page<br><br>

<div style="width:500px;height:500px;border:2px solid red;"><?php  include "second.php" ?></div>

second.php

<?php
$param1 = $_GET['param1'];
$param2 = $_GET['param2'];

?>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script>

    $(document).ready(function(){

          $("#theform").click(function(theevent){
             $("#pre_target").html('<div id="target"></div>');               
                theform();
            });


 })
            function theform() {  
            $("#target").load("form.php", {}, function(){  });

            }  

</script>

I'm the second page

<div id="pre_target">
    <a href="#" id="theform">Go to form</a>
</div>

form.php

<form method="post" action="action.php">
  <input type="hidden" name="ACTION" value="FORM">
<input type="submit" value="submit" name="submit">
</form>

action.php

<?php

switch($_REQUEST["ACTION"]) {

  case "FORM":

   header("Location: second.php#pre_target?param1=OK&param2=OK");

  break;

    .
    .
    .
   ?>

【问题讨论】:

  • 酷你建立一个web?你是怎么做到的? :-p

标签: php jquery ajax html location


【解决方案1】:

如果我正确理解您的问题,只需将“second.php”替换为“first.php”即可。 GET 变量是超级全局变量,这意味着它们是超级全局变量。如果 first.php 包含 second.php,则 second.php 和 first.php 将共享相同的 GET 变量。

header("Location: second.php?param1=OK&param2=OK");

改为:

header("Location: first.php?param1=OK&param2=OK");

【讨论】:

  • 超级全局!!非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-07
  • 1970-01-01
  • 2012-04-15
  • 1970-01-01
  • 2015-08-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多