I've got a JavaScript function defined like this:
function onQuickSearchClick(s) {
var query = s.GetText();
$.post('/Search/', { query: query });
}
Now I want to call the View "Search" with the query-text in the SearchController. How can I do that?
When doing this, no view is shown:
SearchController.cs:
public ActionResult Index(string query)
{
// Can't do "return View(query)" here, because this would be interpreted as the view name
return View();
}
How can I pass the query parameter to my Views/Search/Index.cshtml?
$.post('/Search?query=' + query);querystring to object.return View((object)query);