I'm a relative noob to JavaScript and JQuery, but I've been searching the web for hours to find an answer to this question. I'm trying to populate a JQuery autocomplete function using an array I've made in PHP. This is a snippet of the array:
<?php
$arr = array(
"Abaddon" => "/BlinkDaggerSounds/abad_blink_01.mp3",
"Alchemist" => "/BlinkDaggerSounds/alch_blink_01.mp3",
"Anti Mage" => "/BlinkDaggerSounds/anti_blink_01.mp3",
"Ancient Apparition" => "/BlinkDaggerSounds/appa_blink_01.mp3",
"Axe" => "/BlinkDaggerSounds/axe_blink_01.mp3",
);
?>
And here is the script I'm trying to run:
<script>
$(function() {
var availableTags = <?php echo json_encode($arr); ?>
$( "#auto" ).autocomplete({
source: availableTags;
});
});
</script>
And here is the form:
<form method="post" action="BlinkDaggerQuiz.php" class="answer_box">
<p>Which hero is it? <input type="text" id="auto" name="guess" /></p>
</form>
And my head tags:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="BlinkDaggerQuiz.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
I can't figure out what I'm missing; the autocomplete options will not show in the text box. I've also tried substituting implode() for the json_encode(), but got the same non-results.
var availableTags? Is that variable getting set properly?