AJAX full structure and removal

Source: Internet
Author: User

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

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.