Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple MVC4 unobtrusive ajax not working
    primarykey
    data
    text
    <p>I am writing a very simple MVC4 test page and unobtrusive Ajax does not seem to be working. When I click my submit Button the page is not submitted. </p> <p>I have a breakpoint is VS and can tell there is no request.</p> <p>I am using Firefox and when I click the submit button the Web Console shows this JavaScript error:<br/> --- Empty string passed to getElementById()</p> <p>Which occurs at line 16 in.<br/>--- jquery.unobtrusive-ajax.js</p> <p><br/><br/></p> <p>I setup ajax Options as follows:<br/></p> <pre><code>AjaxOptions ajaxOpts = new AjaxOptions { UpdateTargetId = "officeList", Confirm = "Are you sure?", Url = Url.Action("GetOfficeData") }; </code></pre> <p>Here is my AjaxForm:<br/></p> <pre><code>@using (Ajax.BeginForm("GetOfficeData", ajaxOpts)) { &lt;div&gt; @Html.DropDownList("orgList", new SelectList(Model.Organizations, "ORGID", "ORGNAME")); &lt;button type="submit" id="btnSubmit"&gt;Submit&lt;/button&gt; &lt;/div&gt; } </code></pre> <p>I do get the 'Are you sure prompt' when I click the submit button (as defined in the ajax options).<br /> <br /> <br /></p> <p>If I change Ajax.BeginForm to:<br/></p> <pre><code>@using (Html.BeginForm()) ... </code></pre> <p>Then there is a request, my breakpoints get hit, and there as no JS errors. <br /><br /><br /></p> <p>I have used NuGet to get the latest version of both jQuery and unobtrusive-ajax. Here are my script tags from view source (all of them – in order): <br/></p> <pre><code>&lt;script src="/Scripts/jquery-2.0.3.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/DataTables-1.9.4/media/js/jquery.dataTables.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/jquery.unobtrusive-ajax.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/jquery.validate.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/jquery.validate.unobtrusive.js"&gt;&lt;/script&gt; &lt;script src="/Scripts/modernizr-2.5.3.js"&gt;&lt;/script&gt; </code></pre> <p><br /><br /><br /> Here is the form that gets rendered:</p> <pre><code>&lt;form action="/Selectee/GetOfficeData" data-ajax="true" data-ajax-confirm="Are you sure?" data-ajax-mode="replace" data-ajax-update="#officeList" data-ajax-url="/Selectee/GetOfficeData" id="form0" method="post"&gt; &lt;div&gt; /*--my drop down ..... &lt;br /&gt; &lt;button type="submit" id="btnSubmit"&gt;Submit&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p><br /><br /><br /> Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    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