I am currently implementing an autocomplete module to my site which parses weather information from Weather Underground
$(function(request) {
var cities = []; // setup empty array
$.ajax({
url : "http://autocomplete.wunderground.com/aq?",
query : request.term,
dataType : "json",
success : function(parsed_json) {
for(i = 0; i < parsed_json['RESULTS'].length; i++) {
cities.push(parsed_json['RESULTS'][i]['name'])
}
}
});
$( "#tags" ).autocomplete({
source: cities
});
});
Essentially, I populate an array called cities with the city names when the person types in their search query and it would send s request to Weather Underground's auto-complete API.
Using the variable query : request.term, I try to append the key value query=[search term] to the end of the url. However, when I check the console, it seems the request.term is always empty.
My question is - why is my input parameter empty for the text box?
The text box' id is tags.