Good day. Tell me who knows how to autocomplete on the site? To implement a search for autocompet cities or airports, use a query of the following form:
http://autocomplete.travelpayouts.com/jravia?locale=ru&with_countries=false&q=Mos&callback=function
where q is the main parameter, is set as text; locale is the output language; with_countries - used if autocomplete is created for a country (false - the answer does not contain information about the country, true - the answer contains information about the country); callback - the name of the function in which the answer is returned.
Sample answer:
[ { "_id":"4eda5f858792904be4001433", "coordinates":{ "lon":37.617633, "lat":55.755786 }, "city_fullname":"Москва, Россия", "city_code":"MOW", "name":null, "_type":"city", "_score":67.74186, "city_name":"Москва", "title":"Москва", "country_code":"RU", "country_name":"Россия", "code":"MOW" }, { "_id":"4eda61628792904be4003b20", "coordinates":{ "lon":43.149445, "lat":36.3075 }, "city_fullname":"Мосул, Ирак", "city_code":"OSM", "name":"Мосул", "_type":"airport", "_score":26.681381, "city_name":"Мосул", "title":"Мосул", "country_code":"IQ", "country_name":"Ирак", "code":"OSM" }] Here is a sample code as I try to do:
<!doctype html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> <meta charset="utf-8"> </head> <body> <script> $(document).ready(function(){ $( "#test" ).autocomplete({ source: function(request, response){ $.ajax({ url: "http://autocomplete.travelpayouts.com/jravia?locale=ru&with_countries=false&callback=function", dataType: "jsonp", data:{ q: request.term }, success: function(data){ response($.map(data, function(item){ alert(data); })); } }); }, minLength: 2 }); }); </script> <input id="test"> </body> </html> Thanks in advance.
q, and in the code you passd? - terandata.geonames- teran