Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Сложная структура json (https://javascript.ru/forum/jquery/61022-slozhnaya-struktura-json.html)

рони 01.02.2016 17:30

chelleg,
обычно вариант с json расчитан что сервер будет сортировкой заниматся и подгружать нужное по мере ввода текста;
пробуйте так.
$(document).ready(function() {
    $("#autofrom").autocomplete({
        source: function(request, response) {
            $.ajax({
                url: "http://emspost.ru/api/rest/?method=ems.get.locations&type=cities&plain=true",
                type: "POST",
                dataType: "jsonp",
                success: function(data) {
                    $("#autofrom").autocomplete("option", "source", $.map(data.rsp.locations, function(item) {
                        return {
                            value: item.name,
                            label: item.name
                        }
                    }))
                }
            })
        },
        minLength: 1,
        cache: false,
        delay: 100
    })
});

chelleg 01.02.2016 19:15

Огромное Вам спасибо!
Все заработало!


Часовой пояс GMT +3, время: 05:12.