Ajax.beginform prompts for errors that do not support live properties or methods

Source: Internet
Author: User

Solve:

Download the latest version of Jquery.unobtrusive-ajax.min.js file in NuGet

Ajax Asynchronous requests:

Reference JS:

<Scripttype= "Text/javascript"src= "@Url. Staticfile ("/assets/js/jquery-2.1.1.min.js ")" CharSet= "Utf-8"></Script><Scripttype= "Text/javascript"src= "@Url. Staticfile ("/assets/js/bootstrap.min.js ")" CharSet= "Utf-8"></Script><Scripttype= "Text/javascript"src= "@Url. Staticfile ("/assets/js/plugins/footable/footable.all.min.js ")" CharSet= "Utf-8"></Script><Scripttype= "Text/javascript"src= "@Url. Staticfile ("/assets/js/content.min.js ")" CharSet= "Utf-8"></Script><Scripttype= "Text/javascript"src= "@Url. Staticfile ("/assets/js/layer/layer.js ")" CharSet= "Utf-8"></Script><Scripttype= "Text/javascript"src= "~/scripts/jquery.unobtrusive-ajax.min.js"></Script>

jquery and Jquery.unobtrusive-ajax.min.js must be referenced.

  <Divclass= "Row">            <Divclass= "col-sm-12 animated fadeinright">@using (Ajax.beginform ("Layerupdatestock", "Checkstock", null,new ajaxoptions {httpmethod = "Post", O                    nsuccess = "Tips", Onbegin = "Validatefunction"}) {@Html. Hidden ("ID") <Divclass= "Form-group">                        <Divclass= "Col-sm-3">Amount:</Div>                        <Divclass= "Col-sm-9">@Html. TextBox ("Updatenum", NULL, new {@class = "Form-control"}) /c7></Div>                    </Div>                          <Divclass= "Form-group">                        <Divclass= "Col-sm-3">Note:</Div>                        <Divclass= "Col-sm-9">@Html. TextBox ("Backinfo", NULL, new {@class = "Form-control"})</Div>                    </Div>                                        <Divclass= "Form-group">                        <Divclass= "Col-sm-12 pull-right">                            <Buttonclass= "Btn btn-primary"type= "Submit"><Iclass= "fa Fa-check"></I>&nbsp;Submit</Button>                            <Buttontype= "button"ID= "Layerclose"class= "btn btn btn-primary"Data-dismiss= "Modal"><Iclass= "fa fa-close Blue"></I>&nbsp;Shut down</Button>                        </Div>                    </Div>                }            </Div>        </Div>

callback function before successful return and request:

 functionvalidatefunction () {if(IsNaN (' #UpdateNum '). Val ()) && $ (' #UpdateNum '). val ()! = "") {parent.layer.msg ("Content must be a number"); return false; } } functionTips (data) {if(data = = "OK") {parent.layer.msg ("Modified successfully");         Location.reload (); varindex = Parent.layer.getFrameIndex (window.name);//get the index of the current IFRAME layer firstParent.layer.close (index);//then perform the close}Else{parent.layer.msg ("Modify Failed"); } }

Background:

[HttpPost] [ValidateInput (false)]         Publiccontentresult Layerupdatestock (Checkstock stock) {varModel = This.            Reportdatastatics.getcheckstock (stock.id); Model. UserName= This.            UserContext.LoginInfo.LoginName; Model. Updatenum=stock.            Updatenum; Model. Backinfo=stock.            Backinfo;  This. Tryupdatemodel<checkstock>(model);  This.            Reportdatastatics.savechecksock (model); //Jsonresult json = new Jsonresult (); //JSON.            Data = new {result= "success"}; //return JSON;            returnContent ("OK"); }

Ajax.beginform prompts for errors that do not support live properties or methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.