Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery find()与PHP中的filter()的比较_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript jQuery find()与PHP中的filter()的比较

Javascript jQuery find()与PHP中的filter()的比较,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我试图仅在用户提交表单时刷新div上的内容。页面为.php,action=位于同一页面上。以下是我尝试过的: <?php session_start(); if($_SERVER['REQUEST_METHOD'] == "POST") { if($_POST['user'] === 'mysecret' && $_POST['pass'] === 'page') $_SESSION['auth'] = tr

我试图仅在用户提交表单时刷新div上的内容。页面为.php,action=位于同一页面上。以下是我尝试过的:

<?php

    session_start();
    if($_SERVER['REQUEST_METHOD'] == "POST")
    {
        if($_POST['user'] === 'mysecret' && $_POST['pass'] === 'page')
            $_SESSION['auth'] = true;
    }

    if(isset($_SESSION['auth']))
    {
        ?>
        <html>
        <body>
        <div id="anothercontainer"> </div>
        <div id="container">
        <p id="mycontent"> Here is my new content </p> </div>
        </body> 
        </html>
        <?php
        exit();
    }

?>

<html>
    <body>
        <form id="changing" action="test3.php" method="POST">
            User:
            <input type="text" name="user" />
            Pass:
            <input type="password" name="pass" />
            <input type="submit" value="Send" />

        </form>
        <div id="content"> Here is the content to be updated </div>

        <script src="scripts/jquery-3.2.0.js"></script>
        <script>
            $('#changing').on('submit', function(e) {
                    e.preventDefault();
                    var $content = $('#content');
                    var details = $('#changing').serialize();
                    $.post('test3.php', details, function(data) {
                            $content.html( $(data).find('#container') );
                    });
            });
        </script>
    </body>
</html>
(完整的.js代码在这里:)。
谁能帮帮我吗?因为我真的很困惑。谢谢。

我建议查看。查找将搜索子元素,as筛选器将搜索已选择的元素。
success: function(data) {                               // Show content
  $content.html( $(data).find('#container') ).hide().fadeIn(400);
},