哈哈:)我的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. hdu1536Nim

    sg函数打表的基础应用,第一道ac的sg函数打表题纪念下,直接上代码: hdu1536题目连接 #include<iostream> #include<cstdio> #inc ...

  2. 谈谈ThreadStatic

    可能经常做多线程.线程池的童鞋早就知道这种问题,原谅我一直对线程研究不深. 这个东西好像出现有一段时间了,不过最近我才用到,做的API的服务,用来保存当前请求的上下文内容,原来用过Thread.Set ...

  3. maven 项目 pom.xml文件中配置的jar包下载报错

    [ERROR] [ERROR] Some problems were encountered while processing the POMs:[ERROR] 'dependencies.depen ...

  4. 向量空间(Vector Spaces)

    向量空间(Vector Spaces) 向量空间又称线性空间,是线性代数的中心内容和基本概念之一.在解析几何里引入向量的概念后,是许多问题的处理变得更为简洁和清晰,在此基础上的进一步抽象化,形成了与域 ...

  5. python报错Could not open PYTHONSTARTUP

    root@liqian-python:/pythonShare/monitor/m_server/core# pythonPython 2.7.10 (default, Oct 14 2015, 16 ...

  6. 关于System.currentTimeMillis()

    一.时间的单位转换 1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 微秒(μs) 1微秒=1/1,000,000秒(s)1秒=1,000,000,000 纳秒(ns ...

  7. archive log

    1.查看归档模式 2.查看归档文件所在位置 3.完全恢复和不完全恢复 完全恢复:找到问题产生的时间点,在时间点之后的数据也能同时保留 不完全恢复:只能恢复到产生问题的那个时间点的数据状态. 4.非归档 ...

  8. MongoDB高级查询用法大全

    转载 http://blog.163.com/lgh_2002/blog/static/440175262012052116455/ 详见官方的手册: http://www.mongodb.org/d ...

  9. CentOS6.3添加nginx系统服务详细说明

    今天虚拟机上配了下服务器整理了个这个 nginx 服务 要注意 - 短横杠这个符号看看复制进去后有没有乱码,我之前就遇到这个问题,郁闷了好久才发现 提示:顶部的注释不要去除否则无法注册为系统服务, 关 ...

  10. CodeForces 703D Mishka and Interesting sum

    异或运算性质,离线操作,区间求异或和. 直接求区间出现偶数次数的异或和并不好算,需要计算反面. 首先,很容易求解区间异或和,记为$P$. 例如下面这个序列,$P = A[1]xorA[2]xorA[3 ...