且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JQuery的deferred.done立即执行predefined功能,但声明内无法正常工作

更新时间:2023-02-23 08:54:07

更​​改为:

$.when(first, second).done(logthree);

正在执行 logthree()并通过返回的结果为 .done()。你需要传递一个函数引用 .done()这仅仅是 logthree 没有括号。当您添加括号,即指示JS跨preTER立即执行。这是一个常见的​​错误。

You are executing logthree() and passing the return result to .done(). You need to pass a function reference to .done() which is just logthree without the parens. When you add parens, that instructs the JS interpreter to execute it immediately. This is a common mistake.