I'm trying to make an autocomplete search function with JQuery but the results are not being displayed. In the browser console I can see the requests are working:
This is my Search function
public function getAllartikelSearch()
{
$statement = $this->connection->prepare("SELECT * FROM lievers_serienummers.artikel where artikelNummer like :keyword");
$statement->bindValue('keyword', '%' . $_GET['term'] . '%');
$statement->execute();
$result = array();
while($product = $statement->fetch(PDO::FETCH_OBJ)) {
array_push($result, $product->artikelNummer);
}
echo json_encode($result);
}
This gets called by search.php
<?php
require_once 'database.php';
require_once 'autoloader.php';
$overzichtmanager = new overzichtmanager();
$overzichtmanager->getAllartikelSearch();
?>
And here is the autocomplete code:
<script>
$(document).ready(function () {
$('#tags').autocomplete({
source: 'search.php'
});
});
</script>
<body>
<header>
<h1>Toevoegen</h1>
</header>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" name="term"/>
<div id="countryList"></div>
</div>
