.hide("slow")是同步方法还是异步方法? [英] .hide("slow") is synchronous or Asynchronous method?

查看:283
本文介绍了.hide("slow")是同步方法还是异步方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们知道$.ajax()是异步方法,因为next语句在完全执行ajax()方法之前开始执行,并且'ajax()'继续并行执行其工作,而hide()是同步方法,因为它立即隐藏元素,并且当hide()真正完成其全部任务时,将执行下一条语句,但是对于hide("slow")的情况,我确实感到困惑.似乎是异步的,但我读了它,它在浏览器中设置了计时器,并且所有操作自动发生(现在hide("slow")并行执行任何操作),因此,在某种程度上,在下一条语句开始执行之前,它也已经完成了全部任务,所以似乎也是一种同步方法,

As we know $.ajax() Is a asynchronous method , beacuse next statement starts executing before ajax() method is fully executed and 'ajax()' keep doing his stuff parallelly ,And hide() is a Synchronous method, because it immediately hides the element and next statement will execute when hide() really done his whole task, But I am really confused in the case of hide("slow"). It seems Asynchronous but I read, it sets the timer in browser and everything happen automatically(now hide("slow") is doing nothing parallelly) so in a way , It has also been done its whole task before the next statement start executing ,So hide("slow") also seems a synchronous method ,

我对这个同步异步概念很困惑

I am very confused about this Synchronous Asynchronous concept

有人可以帮助我理解这个概念吗?

Can someone help me to understand this concept ?

推荐答案

.hide("slow")是同步或异步方法

.hide("slow") is synchronous or Asyncronous method

对该方法的调用是同步的,但它启动了异步过程.因此,通常,我们通常将其称为异步方法"(在这种情况下,您要为其指定一个duration参数).

The call to the method is synchronous, but it starts an asynchronous process. So we would normally, loosely, call it an "asynchronous method" (in this case, where you're giving it a duration argument).

调用hide("slow")时,您会同步告诉jQuery start 随时间缓慢隐藏元素的过程.完成对hide的初始调用之后,实际执行此过程的过程将异步进行. (对于ajax也是这样:该方法本身是同步的,但是它启动的过程开始执行XMLHttpRequest的过程是异步进行的.)

When you call hide("slow"), you synchronously tell jQuery to start the process of of hiding the element slowly over time. The process of actually doing that takes place asynchronously, after the initial call to hide is complete. (This is also true of ajax: The method itself is synchronous, but the process it starts — doing the XMLHttpRequest — continues asynchronously.)

通常,如果方法的工作在调用期间 完成,我们将其称为同步方法,但是,如果仅开始工作随后完成,则我们将其称为同步方法.称它为异步方法.从技术上讲,该方法本身不是异步的,只是它启动的整个过程,而是...

Typically if the work of the method is completed during the call to it, we call it a synchronous method, but if it only starts work that completes later, we call it an asynchronous method. Technically the method itself isn't asynchronous, just the overall process that it initiates, but...

hide 本身是同步方法还是异步方法,具体取决于哪个参数( s)您传递它:如果您没有持续时间(.hide())调用它,则它是同步的;如果您使用持续时间(.hide("slow").hide(400))调用它,则它是异步的.

hide itself, of course, is both a synchronous and asynchronous method depending on what argument(s) you pass it: If you call it with no duration (.hide()), it's synchronous; if you call it with a duration (.hide("slow"), .hide(400)), it's asynchronous.

这篇关于.hide("slow")是同步方法还是异步方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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