I want to display the output from the user input.
Hi Guys, I need to display the output from the user input but it seem the output give me an error.
 <label>First Name: </label>
    <input id="fname"></input>
    <br>
    <button id="testing_lang" value="1" onclick="return chk()">
        Test Output
    </button>
    <br>
    <p id="query_result">Result will display here</p>
   <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
   <script>
      function chk()
      {
        var firstName = document.getElementById('fname').value;
        $.ajax({
          type: 'post',
          url: 'test.php',
          data: firstName,
          cache:false,
          success: function(html)
                {
                  $('#query_result').html(html);
                }
         });
        return false;
      }
    </script>
This is the code from my test.php I created
$firstName=$_POST['firstName'];
echo "Response: " .$firstName;
This is the error of the output
Notice: Undefined index: firstName in C:\xampp\htdocs\cops\pages\test.php on line 2 Response:
 
     
    