jeudi 23 juin 2016

Typeahead not populates value

I am using typeahead where i am using ajax call to fetch data from controller. I am getting data in OnSuccess method but it's not populating. Below is my code:

$('#search-input').typeahead({
        hint: true,
        highlight: true,
        minLength: 1
    },
    {
        limit: 12,
        async: true,
        source: function (query, process) {
            return $.ajax({
                url: "/Home/GetJsonData",
                type: 'POST',
                data: { query: query },
                dataType: 'json',
                success: function (json) {
                    debugger;
                    var matches = [];
                    $.each(json, function (i, str) {
                        matches.push(str.name);
                    });
                    return process(matches);
                }
            });
        }
    });
<input type="text" id="search-input" class="form-control" />

How do i achieve the same?

Aucun commentaire:

Enregistrer un commentaire