Record the steps of the front-end AJAX implementation and deletion and modification functions

Source: Internet
Author: User

Mainly relies on three buttons: new, delete, edit

Added: Create a new Li or tr when clicked and append to the parent, there is no need to mobilize the background interface (if the new need to pop the window input Val can be called);

Delete: Determine if this has a background passed the ID value, if not, then the new, can be directly deleted; If there is, you need to pass the ID value to the background, the background delete the record after the front end and then the Li to remove;

Ok (or edit): Gets the Val value of all input, judging: if there is no ID value, add to the array 1 and call the background add new interface, if there is an ID and Val changes (need to pre-save the original value and compare) then put into the array 2 call the Edit interface. Because the AJAX implementation of data transmission is asynchronous, so there is no guarantee that the new interface is finished to execute the editing interface, you can define a variable, the value of the sum of 2 arrays, loop once, variable--when the variable is 0 o'clock, represents the end of the data transfer.

Record the steps of the front-end AJAX implementation and deletion and modification functions

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.