I am trying to get the Json result from the yahoo finance search box and I need it as autocomplete format. I need it generate a div with the result. When I click on a element I need to send it to python script. Here what I done, but does not work, Any help?
$(function() {
$("#find").autocomplete({
source: function(request, response) {
$.ajax({
url: "https://query2.finance.yahoo.com/v1/finance/search?q=" + request.term,
dataType: "json",
data: {
term: request.term
},
success: function(data) {
console.log(data)
var transformed = data.items.map(function(item) {
return {
exchange: item.quotes.exchange,
shortname: item.quotes.shortname,
};
});
response(transformed);
}
});
}
}).autocomplete("instance")._renderItem = function(ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.exchange + "/><br />")
};
});