I've been trying to solve this problem, but no luck.
I'm trying to make an ajax call so that when a user is registering, it will check the server to see if that username is already taken.
In the file /home/myname/public_html/final/js/checkusername.js
$(function(){
    var x_timer;
    $("#Signup_username").keyup(function (e) {
       //document.write( "HELLO");
        clearTimeout(x_timer);
        var user_name = $(this).val();
        x_timer = setTimeout( function() 
             { check_username_ajax(user_name); } 
                             , 1000);         //the function defined in setTimeout is executed after a time delay of 1000 ms
    });
     function check_username_ajax(username) {
        $.ajax({
            url: '/home/myname/public_html/final/php/usernamecheck.php',
            type: "POST",
            data: {'username':username},
          success: function(){
              $('#result').html(data); 
          },
            error: function(XMLHttpRequest, textStatus, errorThrown) { 
        alert("Status: " + textStatus); alert("Error: " + errorThrown); 
    }  
})
    }
});
here is the file usernamecheck.php:
<?php
require_once '/home/myname/public_html/final/db_connect.php';
if(isset($_POST["username"]))
{
   if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
        die();
  }
    $username = filter_var($_POST["username"], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH);
    $statement = $mysqli->prepare("SELECT userid FROM USER WHERE userid=?");
    $statement->bind_param('s', $username);
    $statement->execute();
    $statement->bind_result($username);
    if($statement->fetch()){
        echo('username is not available');
    }else{
        echo('username is available');
    }
}
?>
I keep getting an Error: Not Found message. I'm honestly just at a loss. Everything works fine until I do the ajax call. Please help
 
     
    