1

I'm trying to implement autocomplete for a textbox using the following code, but it's not working: (The ajax call to MyUrl works fine and returns a json string made of List of strings)

$(document).ready(function () {
    $(".searchbox").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/MyUrl/" + request.term.toLowerCase(),
                dataFilter: function (data) { return data; },
                success: function (data) {
                    return data;
                }
            });

        },
        minLength: 1
    });
});

Is this call correct ?

1 Answer 1

4

You're not supposed to return the data, you're supposed to pass it to the response callback.

success: function(data) {
    response(data);
}

Which is pretty much the same thing as:

success: response
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.