title: ajax call occuring internal server error
body: <p>I am doing <code>ajax call</code>. And every time it is failing with occurring a <code>500 Internal server error</code>. But <strong>no error in the client side code</strong>.</p>
  
  <p>JavaScript code:</p>
  
  <pre><code>$.ajax({
      url:"test.php",
      type:"POST",
      dataType:"html",
      data:{
          userInput:userInput /* userInput is some text value */
      }
  });
  </code></pre>
  
  <p>PHP code:</p>
  
  <pre><code>&lt;?php
      $con=mysqli_connect("localhost","root","password","test");
      $user_data=$_POST['userInput'];
      echo $user_data;
  ?&gt;
  </code></pre>
  
  <p>every time I see these error codes in console:</p>
  
  <p><code>POST XHR http://localhost/test.php</code> and <code>[HTTP/1.0 500 Internal Server Error 1ms]</code></p>
  
  <p><em>Ask me if you need more informations</em>.</p>
  
  <p><code>NB</code>:I found many questions in this community. <strong>None of those solved my problem</strong>.</p>