jquery to submit to form form (MVC scheme)

Source: Internet
Author: User

From: http://www.cnblogs.com/lmfeng/archive/2011/06/18/2084325.html

Let me start by explaining that this is the use of ASP.

jquery to submit to form form, here is a form form, there is no action field, we can register the event with jquery to submit,

<form method= "POST" id= "DocumentForm" >
<input type= "hidden" id= "Hidid" name= "Hidid" value= "<%=request.querystring[" id "]%>"/>
<input type= "hidden" id= "hidaction" name= "hidaction" value= "<%=request.querystring[" action "]%>"/>
<div class= "Fieldbody" >
<div class= "Tagsiglebody" >
<table class= "Create" >
<tr>
<th class= "W100" >
Key words:
</th>
&LT;TD class= "NES" >
<input type= "text" id= "Txtkeyword" name= "Txtkeyword" class= "txt w250" value= "<%= viewdata.eval (" keywords ")%> "
Isnull= "0"/>
Please separate the keywords with commas
</td>
</tr>
</table>
</div>
</div>
<div class= "Btngroup" >
<input type= "button" class= "Btncreateok" id= "btnconfirm" value= "create"/>
<input type= "button" class= "Btncreatecancel" onclick= "History.go ( -1)" value= "Cancel"/>
</div>
</form>

The code in JS is as follows:

$ (document). Ready (function () {
$ ("#btnConfirm"). Click (function () {
$ (' #documentForm '). SubmitForm ({
URL: "/document/submitdocumentcreate",
DataType: "Text",
Callback:function (data) {
Endfileupload ();
data = eval ("(" + Data + ")");
Alert (data. Content);
if (data. Result > 0) {
Location.href = data. Redirect;
}
},
Before:function () {
Startfileupload ();
var errmsg = "";
}
}). Submit ();
});

}

In JS, we must note that $ (document). Ready is required, otherwise it will be an error, with the event binding of the button, the ID of the form: $ ("#btnConfirm"). Click, $ (' #documentForm '). SubmitForm

The URL and callback method are then given in the $ (' #documentForm '). SubmitForm method.

Well, this is done, of course, how to get the value of the form in Document/submitdocumentcreate, with request.form["xxxxx", you can get the value of the form.

jquery to submit to form form (MVC scheme)

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.