哈哈:)我的codepen 的代码笔记是:http://codepen.io/shinewaker/pen/eBwPxJ

-------------------------------------------------------

I mean, check it out this code :

<a href="#" id="link">Link</a>
<span>Moving</span> $('#link').click(function () {
console.log("Enter");
$('#link').animate({ width: 200 }, 2000, function() {
console.log("finished");
});
console.log("Exit");
});

as you can see in console, the "animate" function is Asynchronous, and it "fork" the flow of the event handler block code. In fact :

$('#link').click(function () {
console.log("Enter");
asyncFunct();
console.log("Exit");
}); function asyncFunct() {
console.log("finished");
}

follow the flow of the block code!

If I wish to create my function asyncFunct() { } with this behaviour, how can I do it with javascript/jquery? I think there is a strategy without use setTimeout() ​

You cannot make a truly custom asynchronous function. You'll eventually have to leverage on a technology provided natively, such as:

  • setInterval
  • setTimeout
  • requestAnimationFrame
  • XMLHttpRequest
  • WebSocket
  • Worker
  • Some HTML5 APIs such as the File API, Web Database API
  • Technologies that support onload
  • ... many others

In fact, for the animation jQuery uses setInterval.

How can I create an Asynchronous function in Javascript?的更多相关文章

  1. AsyncCalls – Asynchronous function calls

    AsyncCalls – Asynchronous function callsWith AsyncCalls you can execute multiple functions at the sa ...

  2. How to create DB2 user function easily by DB Query Analyzer 6.03

    How to create DB2user function easily by DB Query Analyzer 6.03 Ma Genfeng (Guangdong Unitoll Servic ...

  3. DeprecationWarning: Calling an asynchronous function without callback is deprecated. - how to find where the “function:” is?

    I recently updated my node to 7.2.1 and noticed that there is a warning coming: (node:4346) Deprecat ...

  4. GreenPlum学习笔记:create or replace function创建函数

    原始表数据如下: 需求:现要求按分号“;”将rate_item列进行分割后插入到新的数据表中. CREATE OR REPLACE FUNCTION fun_gp_test_xxx_20181026( ...

  5. CREATE OR REPLACE FUNCTION

    CREATE OR REPLACE FUNCTION SF_Taishou_Ksai_Date(v_receiptNum IN CHAR,                                ...

  6. 理解callback function in javascript

    以下内容主要摘自[1,2] (1)In javascript, functions are first-class objects, which means functions can be used ...

  7. Dreamweaver 扩展开发: Calling a C++ function from JavaScript

    After you understand how C-level extensibility works in Dreamweaver and its dependency on certain da ...

  8. A Few Words on Callbacks and Asynchronous Mechanism In Javascript

    It is said that the one of the most routine work a javascript programmer do is writing codes like &q ...

  9. how to disabled alert function in javascript

    how to disabled alert function in javascript alert 阻塞主线程 default alert; // ƒ alert() { [native code] ...

随机推荐

  1. TCP滑动窗口控制流量的原理

    TCP的滑动窗口机制       TCP这个协议是网络中使用的比较广泛,他是一个面向连接的可靠的传输协议.既然是一个可靠的传输协议就需要对数据进行确认.TCP协议里窗口机制有2种:一种是固定的窗口大小 ...

  2. springmvc注释

    //请求json串(商品信息)    输出json(商品信息) //@RequestBody将请求的商品信息的json串转成itemsCustom对象 //@ResponseBody将itemsCus ...

  3. C# 语言规范_版本5.0 (第7章 表达式)

    1. 表达式 表达式是一个运算符和操作数的序列.本章定义语法.操作数和运算符的计算顺序以及表达式的含义. 1.1 表达式的分类 一个表达式可归类为下列类别之一: 值.每个值都有关联的类型. 变量.每个 ...

  4. Qt出现常量有换行符的错误的解决方法

    可以使用 QString::fromLocal8Bit 来将本地字符编码转换为 Unicode 形式的 QString.

  5. vultr优惠码ssd vps赠送50美金,长期有效

    vultr最新优惠码.vultr vps注册教程,是大家关心的问题.网上流传很多vultr vps优惠码,鱼龙混杂,难以判断.其实,获取vultr优惠赠送美元的方式很简单. 第一种,新用户使用绑定信用 ...

  6. 在一个form里边同时执行搜索和 execl导出功能

    一个form 分搜索 和 导出<form name="searchform" id="searchform" > <input type=&q ...

  7. iOS-OC对象模型

    原文:http://blog.csdn.net/fanyiyao980404514/article/details/44864663 在C++的内存模型中我们知道,我们通过虚函数列表来存储虚函数的虚拟 ...

  8. Excel的 OleDb 连接串的格式(Provider=Microsoft.ACE.OLEDB)

    string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" + filePath + ";Exten ...

  9. java 用hmac-sha1进行签名

    public static String getSignature(String s) throws NoSuchAlgorithmException, UnsupportedEncodingExce ...

  10. JavaScript中时间戳和时间的相互转换

    时间转换成时间戳: var time = new Date(); var timestamp=Date.parse(time)   //毫秒数,得到秒除以1000: 时间戳转成时间: 1.转换成 20 ...