i'm trying to check if a username exists in the db with ajax. I don't know why it doesn't work i tried many things and still get nothing.
this is the code that i'm actually trying. the php code works but doesn't send the result to the ajax function
html >Registration.php
<input class="form-control" onblur="checkUser()" id="Pseudo" type="text name="Pseudo" value="" required>"
<span id="availability" name="availability" value=""> </span>
php >Welcome.php
if(!empty($_POST['Pseudo']))
{
$pseudo = $_POST['Pseudo'];
$connexion = mysqli_connect('localhost', 'root', '', 'database');
if(!$connexion)
{
die('Error during connexion ');
}
$sql = "SELECT * FROM Web_database WHERE Pseudo='$pseudo'";
$result = mysqli_query($connexion, $sql);
echo mysqli_num_rows($result);
}
Javascript > Registration.php
function checkUser()
{
var Pseudo = $('#Pseudo').val();
$.ajax({
url:'Welcome.php',
method:"POST",
data:{Pseudo:Pseudo},
success:function(data)
{
if(data == '0')
{
$('#availability').html('Pseudo correcte');
}
else
{
$('#availability').html('Pseudo déja utilisé');
}
}
});
}