如何在jquery中同步调用函数 [英] how call functions synchronasly in jquery

查看:1518
本文介绍了如何在jquery中同步调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个功能,比如

功能函数1()

{



alert('a' );

//代码

function2()



}函数function2()

{

//代码



}

解决方案

可以你能解释一下你想在这里实现什么吗?



因为我知道所有函数如果一个接一个地写入将以相同的顺序执行。默认情况下,它们只会同步调用。因此,不要在第一个方法中调用第二个方法,而只能在第一个方法之后调用第二个方法。



 function1( ); 
function2();





按顺序调用它们将首先执行第一个方法,然后调用第二个方法。



希望这会对你有所帮助: -



http://stackoverflow.com/questions/ 5187968 /如何-应该-I-调用-3-功能合订单到执行-他们酮后的,其他


i have 2 functions like
function function1()
{

alert(' a');
//code
function2()

}function function2()
{
//code

}

解决方案

Can you please explain a bit what actually you want to achieve here ?

Because as i know all functions if is written one after another will be executed in same order. As by default in JavaScript they will be called synchronously only. So rather than calling the second method within the first method at end you can call the second method after first method only.

function1();
function2();



Calling them in order will execute the first method first and then the second method will be called.

Hope this will be of help to you :-

http://stackoverflow.com/questions/5187968/how-should-i-call-3-functions-in-order-to-execute-them-one-after-the-other


这篇关于如何在jquery中同步调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆