I am using WebGrid in My MVC application , for paging I am using this code
var links = $('a[href*=page], a[href*=sort]');
form = $('form')[0];
links.click(function () {
debugger;
form.attr("action", this.href);
$(this).attr("href", "javascript:");
form.submit();
});
@using (Html.BeginForm(Model.PostToAction, "Leads", FormMethod.Post))
when form.submit() is executed it is Executed as GET and not POST ,
what am I doing wrong ?
UPDATE:
My form is :
<form action="/Leads/DetailsLeads" method="post">
Controller is :
[HttpPost]
public ActionResult DetailsLeads(LeadDetailsViewModel model)
Try adding e.preventDefault() inside of your links.click(function(){} block. Without this, the browser will still attempt to do the action you instructed it to do (a GET request on the clicked link).
var links = $('a[href*=page], a[href*=sort]');
form = $('form')[0];
links.click(function (e) {
e.preventDefault();
debugger;
form.attr("action", this.href);
$(this).attr("href", "javascript:");
form.submit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With