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