An Ajax call in jquery (you need to refer to the jquery code base).
Method 1:
Copy Code code as follows:
$.get (URL, function (data) {
Deal with the data
});
Method 2:
Copy Code code as follows:
Jquery.post (URL, [data], [Success (data, Textstatus, JQXHR)], [DataType])
$.post (Url,postdata, function (data) {
Deal with the data
});
Method 3:
Copy Code code as follows:
$.ajax ({
Type: "POST",//or get
ContentType: "Application/json; Charset=utf-8 ",
Url:url,
Data: "{' Countrymodel ':" + json.stringify (Countrymodel) + "}",
DataType: "JSON",//html,xml,script
Async:true,//true means asynchronous, default is True
Success:function (data) {
Deal with the data
},
Error:function () {
Deal with Error
}
});
Second, Jquery.form plugin Ajax (need to refer to the JQuery code base and Jquery.form plugin)
Ajax calls based on form forms
1.ajaxForm, this method is not submitted immediately when invoked, just stating that the call form is to be submitted in AJAX mode, which is generally in $ (document). Ready method Set.
2.ajaxSubmit, this method will be submitted as soon as it is invoked.
Copy Code code as follows:
var options = {
Target: ' #divToUpdate ',
URL: ' comment.php ',
Success:function () {
Alert (' for your comment! ');
}
};
$ (' #myForm '). Ajaxform (options);
or $ (' #myForm '). Ajaxsubmit (options);
Third, the use of Ajax in MVC
Both of these methods are available,
In addition we can microsoftajax, this must refer to MicrosoftAjax.js, micorsoftmvcajax.js these two files
1.ajax.beginform
Copy Code code as follows:
<%using (Ajax.beginform) ("Action", "Controll", New ajaxoptions
{
Updatetargetid = "Ajaxdiv",
HttpMethod = "POST"
}, new {id = "ajaxform"}))
{%>
<input type= "text" id= "EmployeeId2"/>
<input type= "Submit" value= "Submit"/>
<%}%>
<div id= "Ajaxdiv" >
</div>
2.ajax.actionlink
<%=ajax.actionlink ("Linkname", "Action", "Controll", New ajaxoptions
{
Loadingelementid = "Loadingdiv",
Updatetargetid = "Ajaxdiv",
HttpMethod = "POST"
});%>
<div id= "Ajaxdiv" >
</div>
<div id= "Loadingdiv" >
</div>
Four, Jquery.form and jquery.validate use together
Front-end Code
<script type= "Text/javascript" language= "JavaScript" src= "Http://www.jb51.net/Scripts/jquery-1.4.1.min.js" > </script> <script type= "Text/javascript" language= "JavaScript" src= "http://www.jb51.net/Scripts/" Jquery.validate.min.js "></script> <script type=" Text/javascript "language=" JavaScript "src=" http:// Www.jb51.net/Scripts/jquery.form.js "></script>
Back-end action
Public Partialviewresult Login (string useremail, String Password)
{
//Your code return
Partialview (" Success ");
}
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.