title: Ajax not returning results
body: <p>Alright so I have this code which basically finds the user inside the table users and displays it in alert, but it seems that I am doing something wrong. The log shows "Function is not set" and the alert itself displays that.</p>
  
  <p>This is the HTML form I have for it</p>
  
  <pre><code>&lt;center&gt;&lt;form method='POST' &gt;
      &lt;input id="search_fix" type="text" name="search" placeholder="Search.."&gt;
      &lt;input type="submit" name="submit_menu_search" style="display: none;"&gt;
  &lt;/form&gt;&lt;/center&gt;
  </code></pre>
  
  <p>This is the ajax processing </p>
  
  <pre><code>$(document).ready(function() {
  
      $("#search_fix").keyup(function() {
          var search_text = $(this).val();
  
          if(search_text != '') {
              $.ajax({  
                  url:"handler.php",  
                  method:"POST",  
                  data:{"function":"search_ajax", search:search_text},  
                  dataType:"text",  
                  success:function(data){  
                      $('#search_result').html(data);
                      console.log(data);
                      alert(data);
                  }  
              });  
          }
          else {
  
          }
      });
  
  });
  </code></pre>
  
  <p>And these are my PHP functions that I used to basically search for the term</p>
  
  <pre><code>public function search_ajax($term) {
      $handler = new sql();
      $sql = $handler-&gt;connect();
      $sql-&gt;real_escape_string($term);
  
      $result = $sql-&gt;query("SELECT ime FROM users WHERE ime LIKE '%".$term."%'") or die (mysql_error());
      if($result-&gt;num_rows &gt;= 1){ 
          while($row = $result-&gt;fetch_assoc()) {
              echo $row['ime'];
          }
      }
  
  }
  if(isset($_POST['function'])) {
      switch($_POST['function']) {
      case "search_ajax": {
          require_once "assembly/user.php";
          $user = new User();
          $user-&gt;search_ajax($_POST['search']);
          break;
      }
  
  
      default: {
          echo "Unknown AJAX function handler";
          break;
      }
      }
  }
  else {
      echo "Function is not set";
  }
  </code></pre>