1. Complete AJAX structure
Note: (1) The last one does not ","
(2) Ajax high speed requirements, it is best to have a variety of tips and use of buttons (can invalidate it, prevent repeated loading)
$.ajax ({URL:"ajax/tian.ashx",//Connected service sideData: {"ncode": DD},//Submitted dataType"Post",//How to submitDataType:"JSON",//data type returnedSuccess:function (data) {},//Return data, code with no error executionError:function () {},//code executed on error, typically: Server connection failedBeforesend:function () {},//code that executes when no data is returned, which can be used to prevent duplicate commits (invalidating the control) complete:function () {}//No error and data returned after execution, generally do not use, you can write the return data to execute the statement in Success }); /ajax
2. Delete
Add Delete Dynamically
SS + = "<td><a href=\" #\ "class=\" del\ "un=\" "+ data[i].usersname +" \ "> Delete </a></td>";
Dynamically add using future elements
$(". del"). Live ("Click", function () {varOK = Confirm ("do you want to delete this message? "); if(OK = =false) { return false; } varNames = $ ( This). attr ("un"); varNamec = $ ( This);//You cannot use this $.ajax directly in Ajax ({URL:"ajax/delete.ashx", data: {"uname": Names}, type:"Post", DataType:"JSON", Success:function (aa) {if(Aa.has = ="0") {alert ("Delete failed! "); } Else{alert ("Success! "); YHM=""; XB="0"; MZ="0"; Hanshu ("1", Pag, YHM, XB, MZ); $("#CurrentPage"). Text ("1"); Zong (YHM, XB, MZ); $("#JumpTo_Drop"). Val ("1"); $("#TextBox1"). Val (""); $("#DropDownList1"). Val ("0"); $("#DropDownList2"). Val ("0"); } },//SuccessError:function () {alert ("failed to connect to service side! "); }, Beforesend:function () {Namec.text ("Loading in ..."); }, Complete:function () {Namec.text ("Delete"); } });//Ajax});
3. Attribute extension
Property extension when you are spelling a statement in a generic handler
Gender extension: U.sex.value? " Male ":" Female "
National and other foreign key relations can be directly point out: U. Nation1.nationname
AJAX full structure and removal