Skip to content

Instantly share code, notes, and snippets.

@souri
Created February 6, 2015 14:52
Show Gist options
  • Save souri/4933e2635723340dc5f8 to your computer and use it in GitHub Desktop.
Save souri/4933e2635723340dc5f8 to your computer and use it in GitHub Desktop.
$('#searchinput').autocomplete({
source: function(req,res) {
console.log("req:" + req.term)
$.ajax({
// url: "http://souri-mediaserver.ddns.net:5000/ac/"+req.term,
url: "http://192.168.1.111:5000/ac/" + link[3]+ "/" +req.term,
dataType: "jsonp",
type: "GET",
data: {
term: req.term
},
success: function(data) {
res($.map(data.results, function(source) {
return {
label: source._source.Name,//text comes from a collection of mongo
value: source._source.Name
};
}));
},
error: function(xhr) {
alert(xhr.status + ' : ' + xhr.statusText);
}
});
},
select: function(event, ui) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment