The Done method in Ajax in jquery

Source: Internet
Author: User
Tags min
1 The Done method in Ajax can be used after version 1.5 of jquery. This method has a similar effect as success in Ajax. It must first be after the 1.5 version in jquery.
such as: <link rel= "stylesheet" type= "Text/css" href= "./common/easyui/themes/icon.css" >
<link rel= "stylesheet" type= "Text/css" href= "./common/easyui/themes/default/easyui.css" >

<script type= "Text/javascript" src= "./js/jquery-1.7.min.js" ></script><!--version 1.5--
<script type= "Text/javascript" src= "./common/easyui/jquery.easyui.min.js" ></script>


2 Ajax's done. Parameters can be written as a method. is a parameter that takes the function itself as done
such as: function Submitajax (url,func) {

Alert ("URL:" +url);
Jquery.ajax ({
Url:url,
Type: "Post",
DataType: "JSON",
Success:function (msg) {

}
}). Done (function (msg) {
Alert ("done by the Doing method");
Eval (func+ "(" +msg+ ")");//execute callback function. MSG is a parameter passed back in the background
});
}


3 then call it in JS. The URL is a path. Func is a callback function.
such as: Submitajax (Urlhelper ("Demoservice", "Getdemosbyquery", obj), "showmessage");


function ShowMessage (msg) {
Alert ("Here is the callback function:" +msg);
}
Here the MSG is passed back in the background parameters. by Resp.getwriter (). Print (flag), the value of the flag passed back. is a string.
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.