-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
51 lines (49 loc) · 1.95 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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Query Suggestion!</title>
<link href="QSstyle.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="main">
<h1>Wikipedia Query Suggestion Service</h1>
<input type="text" name="input" id="searchbox" size="20" placeholder="search" onkeyup="sendJson()" />
<p id="results">
</p>
</div>
<script src="https://code.jquery.com/jquery-2.1.3.js" type="text/javascript"></script>
<script type="text/javascript">
function sendJson() {
$.ajax({
type: "POST",
url: "getQuerySuggestions.asmx/SearchTrie",
data: "{ input: '" + document.getElementById("searchbox").value + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
//var result = document.createElement("li");
var results = msg.d;
var len = results.length;
var elementToBuild = document.getElementById("results");
elementToBuild.innerHTML = "";
if (document.getElementById("searchbox").value != "") {
for (var i = 0; i < len; i++) {
var c = results[i];
var res = document.createElement("p");
while (c != '[' && c != ',' && c != ']' && c != '"') {
res.innerHTML += results[i];
i++;
c = results[i];
}
elementToBuild.appendChild(res);
}
}
},
error: function (msg) {
document.body.innerHTML = "ERROR";
}
});
};
</script>
</body>
</html>