The ajax:
$(".searchbar").keyup(function() {
let search = $(".searchbar").val();
if (search.charAt(search.length-1) == " ") {
$.post("search.php", {
search: search
});
}
});
All of this code "works" because ive tested it with console.log()
The problem is search.php is not being opened. I know that its not being opened because ive set a breakpoint in that file with NetBeans and its never hit.
Search.php (unfinished):
<?php
require_once 'core/init.php';
if (Input::exists()) {
$_db = Database::getInstance();
$links[];
$databaseResults[];
$searchTerms[] = explode(' ', Input::get('search'));
foreach ($searchTerms as $searchTerm) {
$databaseResults = $_db->search('links', array("name", "hash", "file_extension", "created"), $searchTerm, "%%");
}
}
?>
Ajax that does work for me:
$(".votebutton").click(function() {
let vote = $(this).val();
let token = $(this).parent().find(".token").val();
let link_hash = $(this).parent().find(".link_hash").val();
$.post("vote.php", {
vote: vote,
token: token,
link_hash: link_hash
});
});