jquery 的 $.get 是异步的吗? [英] Is $.get of jquery asynchronous?
问题描述
我想知道是否应该在我的网站上使用异步调用.我知道要明确指定这个我需要使用
I was wondering whether I should use asynchronous calls on my website or not. I know to specify this explicitly I need to use
$.ajax
然而,最初我尝试使用 $.get
,尽管服务器必须返回大量信息,但我的浏览器并没有卡住,我可以毫无问题地导航.
however initially I tried using $.get
and although the server had to return lots of information, my browser didn't stuck and I could navigate without any problems.
我在网上搜索了一下,但我仍然不能 100% 确定两者之间的区别.
I searched a little bit online about it, however I'm still not 100% certain about the difference between the two.
如果 $.get
是异步的,那么 $.ajax
的意义何在?如果不是,再看看我如何使用 $.get
没有导航问题,使用 $.ajax
有什么意义?
If $.get
is asynchronous then what's the point of $.ajax
? And if it's not, then again seeing how I had no navigation problems with $.get
, what's the point of using $.ajax
?
提前致谢
推荐答案
是的,$.get
是异步的.来自文档:
Yes, $.get
is asynchronous. From the documentation:
这是一个简写的Ajax函数,相当于:
This is a shorthand Ajax function, which is equivalent to:
$.ajax({
url: url,
data: data,
success: success,
dataType: dataType
});
...由于没有 async
选项,async
默认为 true
.(请注意,async
将在 jQuery 的未来版本中完全消失;它会永远成立.)
...and as that doesn't have the async
option, async
defaults to true
. (Note that async
will be going away entirely in a future version of jQuery; it will always be true.)
如果 $.get
是异步的,那么 $.ajax
有什么意义?
If
$.get
is asynchronous then what's the point of$.ajax
?
$.ajax
使您可以控制更多选项.$.get
只是一个快捷方式.
$.ajax
gives you control over lot more options. $.get
is just a shortcut.
这篇关于jquery 的 $.get 是异步的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!