提交联系表后输出错误

时间:2016-08-14 21:51:34

标签: php jquery html ajax

请告诉我代码中的确切错误。

这是我的代码,

的index.php

<!DOCTYPE html> <html lang="en">
    <head>
        <meta charset="UTF-8">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <title></title>
        <script>
            $(document).ready(function(){
              $("#formSubmit").click(function(){
                var name = $("#name").val();
                var password = $("#password").val();

                $.ajax({
                    type: "POST",
                    url: "request.php",
                    data : "username="+name+"&Password="+password,

                    success: function(msg,string,jqXHR)
                        {
                            $("#results").html(msg.name+'<br>'+msg.password);
                        }
                });
              });  
            });
        </script>
    </head>
    <body>
        <form>
            Enter Name : <input type="text" name="name" id="name">
            Enter Password : <input type="password" name="password" id="password">
            <input type="button" name="submit" id="formSubmit" value="Click">
        </form>  
        <div id="results"></div>
    </body> </html>

request.php

<?php

    $name = $_REQUEST['name'];
    $password = $_REQUEST['password'];

    $list = array('name' => $name, 'password'=> $password);

    $output = json_encode($list);

    echo $output;

?>

提交表单时出现以下错误。 enter image description here

请参阅附图

0 个答案:

没有答案