首页 > 解决方案 > 刷新网页时如何保留所需文件

问题描述

我有一个项目要求页面刷新但保留另一个页面的内容,但我不确定为什么我当前的实现不起作用。

我有3个文件如下:

测试6.php

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>
    <script src="jquery.pjax.js"></script>
</head>

<body>
    <?php require_once "test10.php"?>
    <div class="container" id="pjax-container">
        Go to <a href="test9.php">next page</a>.
    </div>

    <script>
        $(document).ready(function() {
            $(document).pjax('a', '#pjax-container');
        });
    </script>
</body>

</html>

测试10.php

<div>
    <h1>Hello</h1>
</div>

test9.php

<h1>this is test9</h1>

刷新test9时如何保留test10的内容?

标签: jquerypjax

解决方案


推荐阅读