kurasa
kurasa

Reputation: 5323

Tokenizing autocomplete jquery plugin not working with ASP.NET MVC

I am using the autocomplete plugin but for some reason it is not getting to the controller when I start typing in the text box.

Has anyone used this? or worked with this? or got a working example? I've tried changing the url to /Referral/Get but still does not work

$("#uxSearch").tokenInput("../Referral/Get",
        {
            hintText: "Type in something",
            noResultsText: "No Results",
            searchingText: "Searching",
            classes: {
                tokenList: "token-input-list-facebook",
                token: "token-input-token-facebook",
                tokenDelete: "token-input-delete-token-facebook",
                selectedToken: "token-input-selected-token-facebook",
                highlightedToken: "token-input-highlighted-token-facebook",
                dropdown: "token-input-dropdown-facebook",
                dropdownItem: "token-input-dropdown-item-facebook",
                dropdownItem2: "token-input-dropdown-item2-facebook",
                selectedDropdownItem: "token-input-selected-dropdown-item-facebook",
                inputToken: "token-input-input-token-facebook"
            }
        });

Upvotes: 1

Views: 1432

Answers (1)

mare
mare

Reputation: 13083

You might show us your global.asax.cs routes. Avoid using ../ in relative URLs with ASP.NET MVC. Rather use it like this with a helper method:

$("#Products").focus().autocomplete('<%=Url.Action("GetProducts", "Product") %>', { ...

(the above is from my autocomplete request)

As Zhaph said, try browsing to the URL manually through browser to see if controller actions work fine.

Upvotes: 2

Related Questions