-
Notifications
You must be signed in to change notification settings - Fork 0
/
elasticSearch.js
37 lines (33 loc) · 1.02 KB
/
elasticSearch.js
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
function showSuggestions(inputString) {
// AJAX SEARCH JAVASCRIPT
if(inputString.length == 0){
document.getElementById('search_output').innerHTML = 'Search field empty!';
}else{
// create xmlhttp request object to exchange data with server behind the scenes
var xmlhttp=new XMLHttpRequest();
// 'onreadystatechange' Defines a function to be called when the readyState property changes
xmlhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200){
document.getElementById("search_output").innerHTML = this.responseText;
}
}
xmlhttp.open('GET', 'suggest_data.php?q='+inputString ,true);
xmlhttp.send();
}
// AJAX SEARCH USING JQUERY
/*
if(inputString.length == 0){
document.getElementById('search_output').innerHTML = 'Search field empty!';
}else{
$.ajax({
url: "suggest_data.php",
method:"GET",
data: { 'q' : inputString},
dataType:'text',
success: function(result){
document.getElementById('search_output').innerHTML = result;
}
});
}
*/
}