0

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?

1
  • Solved the problem. all i had to do was to wrap the JSON results in to the callback as it was using JSONP :). Commented Dec 21, 2010 at 9:05

1 Answer 1

1

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

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

4 Comments

status code?? when i requested that page alone it printed out the JSON. and also when i tried the multple autocomplete sample with an asp.net page with exact same output which came from php. it worked with the php sample, but using asp.net it failed?!.. json was same.
Check the http status (Firebug or something similar) from the request. If its 200, its Ok. But I had that problem
Yeap checked the status and its 200, and its returning a JSON? do i have to do something else to support JSONP?
Sorted it out see above comment :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.