-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
59 lines (56 loc) · 1.35 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html>
<head lang="en">
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<p>Search Suggest Demo: </p>
<input id="txt" type="text" name="search" placeholder="Search.." value="" onpropertychange="handle();" oninput="handle();"/>
<br/>
<p id="msg"></p>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script>
function handle()
{
var searchKey = document.getElementById('txt').value;
var pd = {"searchKey": searchKey};
$.ajax({
type: "post",
url: "/",
data: pd,
success:function(data){
var strs = new Array();
strs = data.split(";");
var res = "";
for (i=0; i<strs.length; i++ ){
res += strs[i] + "<br/>";
}
document.getElementById('msg').innerHTML = res;
//document.getElementById('msg').innerHTML = 'Suggest:' + document.getElementById('txt').value;
//alert(data);
},
error:function(){
alert("error!");
},
});
}
</script>
</body>
</html>