Now more popular using jquery Ajax to achieve some no refresh request effect, this section provides a very simple example of code for your reference, I hope to be able to bring some help to the needs of friends, the code is as follows:
<script type= "Text/javascript" >/* Request Ajax with return value, and pop-up reminder box to remind--------------------------------------------------* * function Getajax (url,parm,callback) {$.ajax ({type: ' Post ', DataType: "Text", Url:url, Data:parm, cache:f
Alse, Async:false, Success:function (msg) {callBack (msg); }}}/* Delete/*url: Represents the request path--------------------------------------------------/function DeleteData (url,id) {var
Parm= ' active=del&id= ' +id; if (id==undefined| |
id== "") {showalertmsg (' Please select a row to delete '); } else {showconfirmmsg ("This operation is not recoverable, are you sure you want to delete it?") ", function (r) {if (R) {Getajax (Url,parm,function (RS) {if (parseint (RS) >0) {Showove Ralertmsg ("Delete succeeded!")
", 2000,4); else if (parseint (rs) = = 0) {showoveralertmsg ("This data is associated and cannot be deleted!")
", 2000, 3); else {showoveralertmsg (delete failed!)
", 2000, 5); }}}})}//Remove function Deleteonclick () {deletedata (' sysmenu_list.aspx ', menu_ID);
} </script>
Async is an abbreviation for asynchronous[asynchronous], which is a bool value default of TRUE. When Async is true, the AJAX request is executed down regardless of whether it is complete or not. The synchronization request temporarily locks the browser and does not perform any action when the request is executing.
Describe the next two days to achieve the function, to determine whether a data database exists, if there is a return error, does not exist can be filled out and submitted. The code is as follows:
Iscompany:function (name) {
var flag = 0;
if (name = = =) {return
false;
} else{
$.ajax ({
type: "POST",
URL: '/checkcompany/name/' + name,
cache:false,
success:function ( Data) {return
data > 0 false:true
}}
}
Through the code above, has been unable to correctly respond to the database has been the name. With the next global variable, the async (default is True) is asynchronously converted to synchronization, and the Ajax return value is successfully obtained. The code is as follows
Iscompany:function (name) {
var flag = 0;
if (name = = =) {return
false;
} else{
$.ajax ({
type: "POST",
URL: '/checkname/name/' + name,
cache:false,
async:false,
Success:function (data) {
flag = data;}}
)
}
Return flag > 0? false:true;
}
The above is the use of the Ajax in jquery to submit data and then by the Web site backstage to the data we submitted to return the content of the data, we hope to learn Ajax help.