JavaScript Asynchronous Programming

Source: Internet
Author: User


1 $.get ($C. apipath+ ' Ucenter/padcharge/findmember ', {id:memberid},function(data) {2      if(data.error) {3        layer.close (memberlayer); 4         padinout (padid,memberid); 5         allpads (); 6     }7 });           

1 function Padinout (padid,memberid,callback) {2         $F. postloading ($C. Apipath + ' ucenter/padcharge/ Padinout ', {id:padid,memberid:memberid},function(data) {3                 if( Callback) callback ()4        }); 5 };

Executes the callback function when the method finishes executing and the callback function is present. At this point, the function is executed by means of a parameter: Padinout (padid,memberid,allpads) callback function is a common method of JS asynchronous programming. However, there is a bad place to use the callback function, which will cause a callback to hell. So ES new standards are also constantly seeking to solve the callback scheme. This is something, this article is written here.

JavaScript Asynchronous Programming

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.