How to add a image in array item (that will be pushed to Autocomplete) with JavaScript / jQuery?
Hello, I'm trying to learn JS by myself and I'm having a lot of issues. Now I will just explain one of them.
I have jQuery Autocomplete in one text input, I want to display a message when don't have the autocomplete results. Now I just show a message (working), but I want to add a GIF loading image.
My code:
$("input[type=search]").autocomplete({
delay: 0,
source: function(request, response) {
populate(request.term, response);
result = $.ui.autocomplete.filter(result, request.term)
// Just prevent to add a lot of "loading" itens to result.
for (var i in result){
if (i.item.type == "loading"){
result.splice(i, 1);
}
var item = {};
item.type = 'loading'
item.label = "Loading.."
item.value = "Loading.."
result.push(item)
}
response(result)
}
What can I do to display a GIF with this code?
-------Edit:
Now I tested the code (this code is a new one) and it's appear don't work. What can be the problem?