I am trying to populate data from database using jquery token-input plugin http://loopj.com/jquery-tokeninput/ .but nothing shows up. I wish to know where i am going wrong.
I ACCEPT ANY ALTERNATIVE APPROACH
Every example i search does not seem to work.
My index page
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
</script>
<script type="text/javascript" src="src/jquery.tokeninput.js"></script>
<link rel="stylesheet" href="styles/token-input.css" type="text/css" />
<link rel="stylesheet" href="styles/token-input-facebook.css" type="text/css" />
<div>
<input type="text" id="tagcool" name="blah" />
<input type="button" value="Submit" />
<script type="text/javascript">
$(document).ready(function() {
$("#tagcool").tokenInput("phpsearch.php", {
theme: "facebook",
preventDuplicates: true,
});
});
</script>
And my PHP page
<?php
$link = mysqli_connect("localhost","root","","dbname") or die("Couldn't make connection.");
$look = $_GET['q'];
$arr = array();
$rs = mysqli_query($link,"SELECT * FROM `country` WHERE name like '%".$look."%'");
# Collect the results
while($obj = mysqli_fetch_object($rs)) {
$arr[] = $obj;
}
# JSON-encode the response
$json_response = json_encode($arr);
# Optionally: Wrap the response in a callback function for JSONP cross-domain support
if($_GET["callback"]) {
$json_response = $_GET["callback"] . "(" . $json_response . ")";
}
# Return the response
echo $json_response;
?>
Example of my db

SELECT id, name FROM countryand the jQuery version is outdated, at least use 1.7+ !