0

I am trying to pass one extra perameter from ajax to controller action function with following ajax code

   $('.search-box-text').autocomplete({

                    delay: 500,

                    minLength: 3,

                    //CitySearchAutoComplete

                   @*source: '@(Url.RouteUrl("ProductSearchAutoComplete"))',*@

                    source: '@(Url.RouteUrl("GetAllProductsName"))',

                   @*source: '@Url.Action("SearchTermAutoComplete", "Catelog")',*@

                    //appendTo: '.search-box',

                    extraParams: { city: 'new' },

                    select: function(event, ui) {

                        $('.search-box-text').val(ui.item.label);

                        return false;
                    }

                });

and prototype of controller action iss as follows

public ActionResult GetAllProductsName(string term,string city)

in controller action term parameter is recieved as expected but city perameter is not recieving the value as expected.can any one please provide me the sollution for this issue.

0

1 Answer 1

1

You can use ajax call for your source as indicated here

$('.search-box-text').autocomplete({

        delay: 500,
        minLength: 3,

        source: function(request, response)
        {
            $.ajax({
                url: '@(Url.RouteUrl("GetAllProductsName"))',
                data: {
                    term: 'myterm'
                    city: 'mycity',

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

        select: function(event, ui) {

            $('.search-box-text').val(ui.item.label);

            return false;
        }

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

Comments

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.