Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Form Post not sending FormCollection to MVC Controller
    primarykey
    data
    text
    <p>I'm attempting to change the data in PartialView within my view via a dropdownlist change in the form. Now if I hit the submit button my form posts no problem and the formcollection is available, however when I try to submit via jquery on a change event the form submits alright but no formcollection</p> <p>Any ideas?</p> <p>This is the submission code</p> <pre><code>$(function() { $('#ddlSelection').change(function() { var form = $("#myForm"); var action = form.attr("action"); var serializedForm = form.serialize(); $.post(action, serializedForm, function() { alert("Finished!") }); }); }); </code></pre> <p>the form is as such</p> <pre><code> &lt;% using (Ajax.BeginForm("myForm", new AjaxOptions { UpdateTargetId = "divItemsList", OnComplete = "ClearForm" })) {%&gt; &lt;%=Html.Label("ddlFilter", "Parent Filter")%&gt; &lt;%=Html.DropDownList("ddlFilter", "Please Select ...")%&gt;&lt;br /&gt; &lt;fieldset&gt; &lt;legend&gt;Filter Option Details&lt;/legend&gt; &lt;p&gt; &lt;label for="Value"&gt;Value:&lt;/label&gt; &lt;%= Html.TextBox("Value") %&gt; &lt;%= Html.ValidationMessage("Value", "*") %&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;%}%&gt; </code></pre> <p><strong>SOLUTION</strong> Ok, should have been paying more attention, the <code>Ajax.Beginform</code> tag does not give the form an id or name, I assume they regard it as uneccessary so the solution is to add the htmlattributes manually. as so ..</p> <pre><code>&lt;% using (Ajax.BeginForm("TheAction", null, new AjaxOptions { UpdateTargetId = "divFilterItemsList", OnComplete = "ClearForm" }, new { ID = "myForm", Name = "myForm" })) {%&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload