I'm having Javascript problem to wait a function done before the below line is called. The previous function is including the Javascript MYSQL Queries calls (one of the library of node.js). Then it will be looks like:

在调用下面一行之前,我有一个Javascript问题要等待一个函数完成。前面的函数包括Javascript MYSQL查询调用(node.js库中的一个)。然后会是:

function first() {
    /**
    * a lot processes to execute
    * including Asynchronous processes
    * like running Queries using Javascript MYSQL Library from node.js
    */
    console.log("I am the first one!");
}

first();
console.log("I am the second one!");

Then when i execute this, it happening like:

当我执行它时,它就像:

I am second one!
I am first one!

How do i make them run by keeping the queue order?

如何通过保持队列顺序来运行它们?

NOTE: Now for everyone who confusing the question, please jump/follow my newly created question again:
Everyone please follow/jump into this new question: Node.js MYSQL to detect the INSERT/UPDATE completeness of a Query?

注意:现在,如果大家对这个问题感到困惑,请继续关注我的新问题:大家请继续关注这个新问题:Node。js MYSQL检测查询的插入/更新完整性?

3 个解决方案

#1


1

Pass a callback to the 2nd function to the call to the 1st function. At the end of the 1st function, invoke theh callback:

将回调传递给第二个函数,以调用第一个函数。在第一个函数的末尾,调用theh回调:

function one(parm, callback) {
    // do something
    callback();
}
function two() {
    // do something else
}

one("my parm", two);

更多相关文章

  1. JavaScript数组操作函数方法详解
  2. JavaScript:使用函数参数检索javascript对象键
  3. 由浅到深的分析Javascript OO之写类方式之一:构造函数
  4. 如何在Node中创建可重用的函数而不编写样板代码
  5. d3。scaleSequential不是一个函数。
  6. 如何在SOF上的新帖子中没有像“Grippie”这样的'onclick'执行Jav
  7. 覆盖odoo 8中的JS函数
  8. JavaScript 函数柯里化(参考《JavaScript模式》)
  9. js中匿名函数的写法

随机推荐

  1. [Android]Android FTP Server
  2. android fragment ontouch 事件
  3. 一次偶然机遇找到一个不错的关于Android
  4. Android锁屏 DevicePolicyManager介绍
  5. [Android] 如何查看当前分支
  6. Android:interpolator用法
  7. Android Battery 架构
  8. android全屏去掉title栏的多种实现方法
  9. android地图开发的主要提供商。
  10. android中如何获取文件的路径总结