Jquery Auto Complete UI not working
Hi All,
I am working on a web application project where I need to add a autocomplete functionality in one of the fields.
I am new to jquery, but I found a post in this forum where they shown how to do an autocomplete using js.
But when I run the code in my machine, its not working, I mean when I type anything into the field it is not showing suggestions below. I don't know where the problem is.
Please throw some light on it.
- <!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="UTF-8" />
<title>jQuery UI Real Autocomplete</title>
javas
<!-- jQuery UI | http://jquery.com/ http://jqueryui.com/ http://jqueryui.com/docs/Theming -->
<style type="text/css">
body{font:62.5% Verdana,Arial,sans-serif}</style>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js"></script>
- </head>
<body>
- <label for="tags">Tags:</label>
<input id="tags" value="">
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript personal",
"Lisp useful",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
alert('works');
$( "#tags" ).autocomplete({
alert('works');
source: function(request, response) {
var filteredArray = $.map(availableTags, function(item
) {
alert(item);
if(item.indexOf(request.term) == 0){
return item;
}
else{
return null;
}
});
response(filteredArray);
}
});
});
</script>
</body>
</html>