Aneef
Aneef

Reputation: 3729

JQuery AutoComplete with ASP.Net

Below is my JavaScript

    <script>
    $(function () {
        function log(message) {
            $("<div/>").text(message).prependTo("#log");
            $("#log").attr("scrollTop", 0);
        }

        $("#city").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "getpostcodes.aspx",
                    dataType: "jsonp",
                    data: {
                        like: request.term
                    },
                    success: function (data) {
                        response($.map(data.RegionList, function (item) {
                                return {
                                label: item.Detail,
                                value: item.Detail
                            }
                        }));
                    }
                });
            },
            minLength: 2,
            select: function (event, ui) {
                log(ui.item ?
                "Selected: " + ui.item.label :
                "Nothing selected, input was " + this.value);
            },
            open: function () {
                $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
            },
            close: function () {
                $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
            }
        });
    });
</script>

And below is my JSON Returned by the server

{"RegionList":[{"Detail":"2250, GOSFORD"}]} 

But my auto complete doesn't show up the result? am i doing anything wrong?

Upvotes: 0

Views: 575

Answers (1)

knokio
knokio

Reputation: 2040

What is the HTTP Status code response? I had problemas sometimes because I received the answer, but the status code was 500

Upvotes: 1

Related Questions