标签:方式 概念 同步请求 display color 序列 连续 response 指定
1.函数使得对不连续事件的处理变得更easy。比如,假定有这么一个序列。由用户交互行为触发,向server发送请求。终于显示server的响应。
最自然的写法可能会是这种:
request = prepare_the_request(); response = send_request-synchronously(request); display(response);
request = prepare_the_request();
send_request-synchronously(request,function(response){
      display(response);
});
以上这部分事实上已经解释了回调函数的使用方法,接下来再举个样例,简单点说明就是把方法a当做一个參数传递给方法mian,当方法mian运行完后运行另外一个指定函数(a)。这里a就是回调函数
function main(callback)   
        {      
            alert("main fun");
            callback();   
        }   
        function a(){   
            alert("a fun");   
        }       
        main(a);  
标签:方式 概念 同步请求 display color 序列 连续 response 指定
原文地址:http://www.cnblogs.com/clnchanpin/p/6853273.html