Submitting Form with Jquery submitting Get instead Post

asp.net-mvc, asp.net-mvc-3, jquery, webgrid

Solution

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();
        });

Problem

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) ```

Original source