I'm using bootstrap typeahead and I have the following code:
Script.js
$('#demo7').typeahead({
ajax: {
method: "POST",
dataType: "JSON",
url: '@Url.Action("List", "Partials")',
data: { something: 35 },
triggerLength: 1
},
scrollBar: true,
displayField: 'Name'
});
PartialsController.cs
[HttpPost]
public JsonResult List(string query, string something)
{
try
{
return Json(this.GetList());
}
catch (Exception ex)
{
throw;
}
}
And I want to know how can I pass extra parameters to the controller, I try to put data: { something: 35 } in AJAX call but in the controller this parameter is always null... any idea to pass extra parameters? Thank you!
In Option, you can use Source, and then do an ajax call normally. Have a look at this https://gist.github.com/thorst/2960885