Good day. Tell me who knows. There is a code

$(document).ready(function(){ $( "#test" ).autocomplete({ source: function(request, response){ $.ajax({ url: 'http://engine.hotellook.com/api/v2/lookup.json?lang=ru&lookFor=hotel&limit=5', data:{ query: request.term }, dataType: "json", success: function(data) { response($.map(data, function(v){ var text = v.locationName; return text; })); } }); }, minLength: 2 }); }); 

Jquery and jquery ui are connected but for some reason this code does not work.

    1 answer 1

    The code works. But you do not correctly handle the results.

     $(document).ready(function(){ $("#test").autocomplete({ source: function(request, response){ $.ajax({ url: 'http://engine.hotellook.com/api/v2/lookup.json?lang=ru&lookFor=hotel&limit=5', data:{ query: request.term }, dataType: "json", success: function(data) { response($.map(data.results.hotels, function(v){ // ^^^^^^^^^^^^^^^^^^^ return v.locationName; })); } }); }, minLength: 2 }); }); 

    Such code is very easy to debug using Chrome Dev Tools or FireBug.