I want to call the actionlink using jquery , below is the code:
$("#paycheck").click(function () {
if ($("#terms").attr("checked")) {
//Call Html.ActionLink // This is where the html.ActionLink should be called to display another view
} else {
alert("Please agree to the terms and conditions.");
return false;
}
});
<%: Html.ActionLink("Pay", "Index", "News") %>
You don’t call an actionlink using jQuery. You could send an AJAX request to the controller action this link is pointing to. If this is what you want, here’s how to achieve
it:
Also make sure you provide a correct id (
paycheck) to your action link when generating itBut if it is only a matter of checking whether the user accepted the terms and conditions and then perform a standard redirect to the controller action without any AJAX, simply do this: