ASP.NET / Ajax - How do you pass a parameter in your call?

Kytxas

New Member
I am trying to filter down my results and can't figure out how to set up the ajax query to work properly with the select2 (http://ivaynberg.github.com/select2/#documentation) drop down. From what I can tell you are supposed to use data, but that is not passing just the value in and filtering down my call.Here is my ajax:\[code\] $('#e1').select2({ placeholder: "Select an ingredient...", minimumInputLength: 2, ajax: { url: "../api/IngredientChoices", data: 'mi', dataType: "json", quietMillis: 500, data: function (term, page) { return { q: term, page_limit: 10, page: page }; }, results: function (data, page) { var more = (page * 10) < data.length; console.log(more); console.log(data); return { results: data, more: more }; }, formatResult: function (post) { markup = '<strong>' + post.text + '</strong>'; } } });\[/code\]Here is my controller:\[code\] public List<Models.IngredientChoices> Get(string param) { var choices = (from i in _context.IngredientItems_View(param) select new Models.IngredientChoices { id = i.ItemID, text = i.ConcatName, }); return choices.ToList(); }\[/code\]The ajax call returns all values currently.
 
Back
Top