0

Please let me know what the exactly error in my code.

Here is my code,

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;

?>

I get the following error when I submit the form. enter image description here

Please see the attached image

John Conde
  • 217,595
  • 99
  • 455
  • 496
Sandeep Kumar
  • 159
  • 3
  • 12

0 Answers0