Three ways in which form forms are submitted in MVC (recommended) _javascript tips

Source: Internet
Author: User

The first way: Submit button Submission

<form action= "Mydemand" method= "POST" >
<span> keyword:</span> <input name=
"keywords" type= "Text" value= "@keywords"/>
<input type= "Submit" value= "search"/>
</form>

The second way: $ ("#dataform"). Ajaxsubmit () Submit

<form id= "DataForm" action= "Updateuserinfo" enctype= "Multipart/form-data" method= "POST" > <table style= " width:100%;border:0; "cellpadding=" 0 "cellspacing=" 0 "> <tbody> <tr> <td width=" "> Name: &LT;/TD > <td><input type= "text" name= "Nvc_name" id= "Nvc_name" value= "@Model. Nvc_name"/></td> </tr > <tr> <td colspan= "2" align= "center" > <input type= "button" value= "Save" id= "Btnsubmit"/> </td > </tr> </tbody> </table> </form> <script src= "http://code.jquery.com/ Jquery-1.11.0.min.js "></script> <script src=" Http://malsup.github.io/jquery.form.js "></script >//ajaxform Dependent script <script type= "Text/javascript" > $ (document). Ready (function () {$ ("#btnsubmit"). Click (
function () {if ($ ("[name= ' Nvc_name ']"). val () = "") {alert ("Please fill in the name");
$ ("[name= ' Nvc_name ']"). focus ();
Return
$ ("#dataform"). Ajaxsubmit (function (r) {alert (r.msg); if (r.success) {location.reload ();}})
});</script> 

The Third Way: Post submission

<table style= "width:100%;border:0px" cellpadding= "0" cellspacing= "0" >
<tbody>
<tr>
<td width= "15%" align= "right" > Mobile number:</td> <td><input
"text" type= "Please enter your mobile number" Id= "Nvc_user_name"/></td>
</tr>
<tr>
<td colspan= "2" align= "Center" >
<input type= "button" value= "Save" id= "Btnsubmit"/>
</td>
</tr>
</tbody >
</table>
<script type= "Text/javascript" >
$ (function () {
$ ("#btnsubmit"). Click (function () {
var nvc_user_name = document.getElementById (' nvc_user_name ');
$.post ('/interface/modefiypwd ', {
nvc_user_name:nvc_user_name.value,
}, function (data) {
if ( data.success) {
$ ("#successdiv"). Show ();
$ ("#editdiv"). Hide ();
else {
layer.msg (data. MSG);
}
}
); </script>

The above is a small set to introduce the MVC in the form of forms submitted in three ways (recommended), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

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.