-
Notifications
You must be signed in to change notification settings - Fork 5
/
single_value_ajax_example.html
49 lines (42 loc) · 2.06 KB
/
single_value_ajax_example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>example</title>
<link rel="stylesheet" href="autocomplete.css" type="text/css" media="screen" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="lib/prototype.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/scriptaculous.js"></script>
<script type="text/javascript" charset="utf-8" src="lib/effects.js"></script>
<script type="text/javascript" charset="utf-8" src="src/fast_autocompleter.js"></script>
<script type="text/javascript" charset="utf-8">
function lookup(searchString, callback) {
new Ajax.Request('/users/autocomplete', { parameters: {name: searchString, rand: (new Date()).getTime()},
onSuccess: function(response) {
callback(response.responseJSON);
} });
}
var cachedBackend = new Autocompleter.Cache(lookup, {choices: 10});
var cachedLookup = cachedBackend.lookup.bind(cachedBackend);
</script>
</head>
<body>
<form action="single_value_ajax_example.html" method="get" accept-charset="utf-8">
<p>
<input type="text" id="autocomplete" name="autocomplete_parameter"/>
<div id="autocomplete_choices" class="autocomplete"></div>
</p>
<p>
<input type="text" id="caching_autocomplete" name="caching_autocomplete_parameter"/>
<div id="caching_autocomplete_choices" class="autocomplete"></div>
</p>
<p>
<input type="submit" value="Continue →">
</p>
</form>
<script type="text/javascript" charset="utf-8">
new Autocompleter.Json("autocomplete", "autocomplete_choices", lookup, {});
new Autocompleter.Json("caching_autocomplete", "caching_autocomplete_choices", cachedLookup, {});
</script>
</body>
</html>