Uncaught TypeError: autocomplete is not a function in jQuery
I'm struggling to work with jQuery autocomplete to fill a HTML input from database. I wrote the whole code, but I still get this error
Uncaught TypeError: autocomplete is not a function in jQuery
and I can't understand why.
Here is my code:
gethint.php
<?php
require_once ('connect.php');
$q=$_REQUEST["q"];
$sql="SELECT nume FROM angajati WHERE nume LIKE '%$q%'";
$result = mysql_query($sql);
$json=array();
while($row = mysql_fetch_array($result)) {
array_push($json, $row['nume']);
}
echo json_encode($json);
?>
profile_admin.php:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Forms</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/datepicker3.css" rel="stylesheet">
<link href="css/profile.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<?php
require('connect.php');
//3. If the form is submitted or not.
//3.1 If the form is submitted
$username = "";
date_default_timezone_set('Europe/Bucharest');
// setting the current date and time
$date = date('Y-m-d H:i:s');
if (isset($_GET['user'])){
//3.1.1 Assigning posted values to variables.
$username = $_GET['user'];
}
else{
die("Nu esti logat");
}
$query = "SELECT * FROM angajati INNER JOIN conturi on conturi.id = angajati.id_cont INNER JOIN incadrare on angajati.id_incadrare=incadrare.id WHERE username='$username'";
$result = mysqli_query($connection, $query) or die(mysqli_error($connection));
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$id = $row["id"];
$name = $row["nume"];
$prenume = $row["prenume"];
$departament = $row["departament"];
$data_angajarii = $row["data_angajarii"];
$data_nasterii = $row["data_nasterii"];
$telefon = $row["telefon"];
$email = $row["email"];
$adresa = $row["adresa"];
$poza = $row["poza"];
$titlu = $row["titlu"];
}
}
else{
die("Nu esti logat");
}
?>
<body>
<div class="container">
<div class="row">
<div class="col-md-5 toppad pull-right col-md-offset-3 ">
<br>
<p class=" text-info"><?php echo $date; ?></p>
</div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xs-offset-0 col-sm-offset-0 col-md-offset-3 col-lg-offset-3 toppad" >
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Buna venit, <?php echo $name." ".$prenume ?></h3>
</div>
<div class="panel-body">
<div class="row">
<div class=" col-md-9 col-lg-9 ">
<table class="table table-user-information">
<tbody>
<form role="form" action="login.php" method="post">
<fieldset>
<div class="form-group">
<input type="text" name="hint" placeholder="Caută un angajat!" class="form-username form-control" id="hint">
</div>
<center><button type="submit" style="width:200px;" class="btn">Caută!</button></center>
</fieldset>
</form>
</tbody>
</table>
<a href="#" class="btn btn-primary">My Sales Performance</a>
<a href="#" class="btn btn-primary">Team Sales Performance</a>
</div>
</div>
</div
</div>
</div>
</div>
</div>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/chart.min.js"></script>
<script src="js/chart-data.js"></script>
<script src="js/easypiechart.js"></script>
<script src="js/easypiechart-data.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/profile.js"></script>
<script type="text/javascript">
$(function() {
$( "#hint" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "gethint.php",
dataType: "jsonp",
data: {
q: request.term
},
success: function( data ) {
response( data );
}
});
},
});
});
</script>
</body>
</html>
Thanks in advance!