javascript - Ajax.Beginform is submitting only once mvc -


hello creating advance search form ajax.beginform called jquery .submit() event, ajax.beginform returns partialview , update div on page. when press search button first time works fine , page updated when try press again the form never submitted , controller action never called. when checked firebug found error showing in console every time press search button:

    typeerror: $.validator.methods[method] undefined       result = $.validator.methods[ method ].call( this, val, element, rule.parameters... 

and code:

the ajax beginfirm view:

     @using (ajax.beginform("advancedsearch", null, new ajaxoptions { updatetargetid = "searchresults", insertionmode = insertionmode.replace }, new { id = "advancedsearchform"})) 

the jquery function:

function submitadvancedsearch() {         if ($("#name").val().trim() == "" && $("#lastname").val().trim() == "" && $("#company").val().trim() == "" ) {             $("#resulterror").text("enter @ least 1 search criteria");     }     else {          $("#resulterror").text("");          $("#advancedsearchform").submit();          $("#advancedclientssearch").prop("hidden", false);     } } 

and button:

    <input type="button" value="search" class="btn btn-primary" onclick="submitadvancedsearch()" /> 

this bundle packages:

                bundles.add(new scriptbundle("~/bundles/jquery").include(                     "~/scripts/jquery-{version}.js",                     "~/scripts/jquery-ui-{version}.js",                     "~/scripts/jquery.unobtrusive-ajax.js",                     "~/scripts/datatables/jquery.datatables.js",                     "~/scripts/datatables/jquery.datatables.min.js"));                  bundles.add(new scriptbundle("~/bundles/jqueryval").include(                     "~/scripts/jquery.validate.js",                     "~/scripts/jquery.validate.unobtrusive.js",                     "~/scripts/jquery.validate*")); 

nb: using mvc5 , jquery javascript library v2.1.3

if not need auto validation remove "~/bundles/jqueryval" bundle.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -