How do I implement autocomplete using nodejs, sockjs and jquery ui autocomplete feature?
Here's the script part
function DocumentReady() {
$("#movieTitle").autocomplete({
minLength: 3,
source: function() {
var title = $("#movieTitle").val();
sock.send(title);
},
delay: 1000
})
}
$(document).ready(DocumentReady);
var sock = new SockJS('http://localhost:9999/ws');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(e) {
console.log('message', e.data);
};
sock.onclose = function() {
console.log('close');
};
I'm sending the data to server and I'm receiving the json response without problems. I don't know what should I put in either autocomplete's source function or onmessage event that would allow me to populate the autocomplete list after receiving the data.