Updated search function to have AJAX calls to the server