asp.net mvc 4 - Simple MVC4 unobtrusive ajax not working -


i writing simple mvc4 test page , unobtrusive ajax not seem working. when click submit button page not submitted.

i have breakpoint vs , can tell there no request.

i using firefox , when click submit button web console shows javascript error:
--- empty string passed getelementbyid()

which occurs @ line 16 in.
--- jquery.unobtrusive-ajax.js



i setup ajax options follows:

ajaxoptions ajaxopts = new ajaxoptions { updatetargetid = "officelist", confirm = "are sure?", url = url.action("getofficedata") }; 

here ajaxform:

@using (ajax.beginform("getofficedata", ajaxopts)) {     <div>         @html.dropdownlist("orglist", new selectlist(model.organizations, "orgid", "orgname"));          <button type="submit" id="btnsubmit">submit</button>      </div> } 

i 'are sure prompt' when click submit button (as defined in ajax options).


if change ajax.beginform to:

@using (html.beginform()) ... 

then there request, breakpoints hit, , there no js errors.


i have used nuget latest version of both jquery , unobtrusive-ajax. here script tags view source (all of them – in order):

<script src="/scripts/jquery-2.0.3.js"></script> <script src="/scripts/datatables-1.9.4/media/js/jquery.datatables.js"></script> <script src="/scripts/jquery.unobtrusive-ajax.js"></script> <script src="/scripts/jquery.validate.js"></script> <script src="/scripts/jquery.validate.unobtrusive.js"></script> <script src="/scripts/modernizr-2.5.3.js"></script> 




here form gets rendered:

<form action="/selectee/getofficedata" data-ajax="true" data-ajax-confirm="are sure?" data-ajax-mode="replace" data-ajax-update="#officelist" data-ajax-url="/selectee/getofficedata" id="form0" method="post">                <div>       /*--my drop down .....       <br />       <button type="submit" id="btnsubmit">submit</button>     </div> </form>   




ideas?

i have working.

i did not have html.beginform(), ajax.beginform(). valid?

i added html.beginform() ajax.beginform() , controls inside form , started working.

i thought ajax.beginform() took place of html.beginform, appears need both. correct?


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -