-1

我有个问题。我用 jQuery、jQuery-ui、jQuery mobile 和 kineticjs 制作了一个 HTML 和 PHP 页面。切换到另一个页面时,不要刷新整个页面。我也尝试使用<meta http-equiv="refresh" content="URL=aa.php">但没有用。在该页面中,我还使用 php 从该 PHP 中获取结果。这是我的 php 页面中的代码:

<?php
    if ( isset($_POST['address']) && isset($_POST['prefix']) && isset($_POST['levels']) ) {
        require_once 'convert.php';
        $network = new Network($ip, $prefix, $levels);
        print_html($network);
        exit();
    }
?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="refresh" content="URL=aa.php">
        <title>aa</title>
        <link rel="stylesheet" href="css/jquery-ui.css" />
        <link rel="stylesheet" href="css/jquery.mobile-1.3.0.css" />
        <script src="js/jquery-1.9.1.js"></script>
        <script src="js/jquery.mobile-1.3.0.js"></script>
        <script src="js/jquery-ui.js"></script>
        <script src="js/kinetic-v4.3.2-beta.js"></script>
    </head>
    <body>
        <div data-role="page">
            <div data-role="header">
                <h3>aa</h3>
            </div>
            <div data-role="content">
                <h3>aa</h3>
                <br />
                <div>
                    <label for="address">Address:</label>
                    <input type="text" id="address">
                    <select id="prefix">
                        <?php for ( $i = 49; $i < 64; $i++ ) : ?>
                        <option value="<?php echo $i; ?>">/<?php echo $i; ?></option>
                        <?php endfor; ?>
                    </select>
                    <label for="subnet">Total Subnets: </label>
                    <input type="text" id="subnets">
                    <button class="btn" id="build"> Build It </button>
                </div>

                <div id="network"></div>
            </div>
        </div>

        <script src="js/jquery.js"></script>    
        <script type="text/javascript">
            $(function(){
                $("#build").click(function(){
                    var subnets = parseInt( $("#subnets").val() );
                    var address = $("#address").val();
                    var prefix = $("#prefix").val();
                    var levels = $("#subnets").val();
                    $.post("aa.php", {address:address, prefix:prefix, levels:levels}, function(response){
                        $("#network").html(response);
                        $("#network > .branch").show();
                        $("#network .open-children").click(function(){
                            $(this).text('-');
                            $(this).parent().children(".branch").toggle();
                            return false;
                        });
                    });
                });
            });
        </script>
    </body>
</html>

问题是否来自太多的javascript?

4

4 回答 4

0

您可以使用此 javascript 代码刷新您的页面:

document.location.reload();

或根据需要更改您的位置:

document.location = "http://google.com";
于 2013-04-08T08:56:37.683 回答
0

元刷新应该这样工作:

<meta http-equiv="refresh" content="0;url=aa.php">
于 2013-04-08T08:52:02.733 回答
0

你可以在没有 JS 的情况下使用它。

<noscript><meta http-equiv="refresh" content="0;URL='?nojs=1'"></noscript>

检查控制台中是否有任何错误并将其删除。此外,您应该检测您是否拥有移动版或 PC 版浏览器,并包括 jquery-1.9.1.js 或 jquery.mobile-1.3.0.js

你也可以使用

窗口位置

使用 setInterval 或 setTimeout 它会做同样的事情。但是你不能有任何 JS 错误。

于 2013-04-08T08:54:33.360 回答
0

尝试这个,

<meta http-equiv="refresh" content="0;url=aa.php">
于 2013-04-08T09:02:39.293 回答