Ajax作为响应返回整页

I've website which make user type Id and check Id through some if conditions , It works well but I want to make it by Ajax ,so How can I use the Id entered by User and pass it through the if conditions without refreshing ? Can it be done even or I'm missing something

I tried to get ajax response by post but it respond with all page content

 // My PHP Code 
  <?php
   if(isset($_POST['Sub'])){
    if(!empty($_POST['Id'])){
      $BlockedRows =
      RowCountDB("Id","blocked","TeacherId",
      $TeacherId['Id'],"StudentId",$_SESSION['Id']);
      if($BlockedRows == 0){ //Not Blocked 
        InsertDB("registerduserstid","UserId",
         $_SESSION['Id'],"TeacherId",$Id);
       }else{ //Blocked
      ?>
        <div class="alert alert-danger alert-dismissible"><a href='#' 
         class='close' data-dismiss='alert' aria-label='close'>&times</a> 
        <b>You are Blocked!</b></div>
        <?php
         }
      }   
   }
  ?>
 // My HTML Code
  <form id="TeachersMenuForm" class="form" action="Home.php? 
    task=TeachersMenu" method="post">
     <div class="row">
        <div class="col-8">
           <i class="far fa-id-badge Id"></i>
           <input type="text" class="Input form-control TeacherID" 
           placeholder="Id" name="Id">
         </div>
         <div class="col-2.5">
           <button name="Sub" class="btn btn-md btn-primary"><i 
           class="fas fa-plus"></i> Enter</button>
          </div>
        </div>
 </form>
 // My Ajax Code
  $("#TeachersMenuForm").on('submit', function () {
    var Url = $(this).attr("action"),
        Type = $(this).attr("method"),
        Id = $(".TeacherID").val();
    $.post({
        type: Type,
        data: "Id="+Id,
        url: Url,
        success: function (response) {
            console.log(response);
        }
    });
    return false;
});

I want to be responded by Id entered by user