来自PHP的数据包括在使用变量变量时未在父级中显示

时间:2014-01-02 16:03:41

标签: php jquery

我遇到以下问题。通过单击start.php中的按钮,将使用参数DE2调用文件fakten02.php。此参数用作变量变量,将数组$DE2转换为字符串并在start.php中显示。不幸的是,这不会发生。如果使用参数直接调用fakten02.php,则可以正常工作。如果参数在fakten02.php中是硬编码的,则$land的内容将显示在start.php中。但是,如果从$land填充$text2,则{。1}}在start.php中为空。

start.php

$land

fakten02.php

<!DOCTYPE HTML>
<html>
    <head>
        <title>Start</title>
    </head>
    <body>
        <div id="spalten">
            <button type="submit" id="land1">Klicken</button>
        </div>
        <?php
            include("fakten02.php");
            print_r($land);
        ?>
    </body>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $("#spalten > button").click(function() {
                $.get("fakten02.php", {sland:'DE2'});
                <?php echo $land; ?>;
            })
        })
    </script>
</html>

我不明白这种行为。我在这里和谷歌上做了很多搜索,但我找不到类似的问题。我该如何解决这个问题?

0 个答案:

没有答案