1

I have searched many times and find examples which match my code structure perfect. Yet I am not getting the results from my ajax to display on the input box.

I get results from the POST that have been evaulated with firebug and everything looks great.

Here is the javascript im using.

<script type="text/javascript" language="javascript">
$(function () {

    $("input.FamousPerson-List").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/FamousPeople/FPPAutoComplete",
                type: "POST",
                dataType: "json",
                data: {
                    searchText: request.term,
                    maxResults: 12
                },
                success: function (data) {
                    response($.map(data, function (item) {
                        return {
                            value: item.DisplayName
                        }
                    }))
                }
            });
        }
    });

});

Here is a link of the actual code I am using on the web.AutoCompleteTesting Type just about any letter in one of the boxes below to invoke it.

Thanks.

2
  • I tried entering text in the boxes and your success function isn't invoked. Free market research: I want to bet on which celebrities will get fat. I want to trade cellulite futures on pop stars. Commented Apr 6, 2011 at 21:59
  • Well thank you, what am I doing wrong that the success function isn't kicking off? And thank you for the suggestion. The Project is open source and I will be looking for ideas. Commented Apr 6, 2011 at 22:14

1 Answer 1

2

If you look closely at the request being sent up, you'll notice that a callback parameter is being added. Weird, right? Since you're doing a local AJAX post, not a cross-domain (JSONP) one.

I noticed that your project includes jQuery Validate. According to this answer to a question dealing with a similar problem (performing a JSONP request instead of a normal JSON request even though you asked for one), it's a known issue in jQuery validate.

Judging by the other answer, you can change your version of jQuery or perhaps use a patched version of jQuery validate (found here).

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

1 Comment

Amazing. Removing the conflicting jQuery Validation version being brought in by the partial view fixes this. Thanks a bunch. The same link above now shows a working solution.

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.