After reading some information I thought this should work. The JS function is called and jQuery animation is spinning, but the action is not posted to. As well I will want the startDate and endDate to be provided from text inputs but for now even hard-coded is not working. Thanks everyone!
Controller:
public class NewsController : Controller
{
[HttpPost]
public ActionResult Search(string lang, string pageNumber, string startDate, string endDate, string search)
{
}
}
View:
@using (Html.BeginForm())
{
<a href="#" id="go_button">...</a>
}
<script type="text/javascript">
$('#go_button').click(function () {
$.post("/News/Search", { startDate: 'start', endDate: 'end'});
});
Make sure that the script is either located after the anchor in the DOM or wrap in a
document.ready:This should work, at least it should invoke your action. What this action does, whether it throws an exception or something is another matter, but at least you should get into it and have the
startDateandendDateparameters properly assigned: