为$不用彷徨的jQuery异步的? [英] Is $.get of jquery asynchronous?

查看:140
本文介绍了为$不用彷徨的jQuery异步的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道我是否应该用在我的网站或没有异步调用。我知道明确指定这一点,我需要用

  $。阿贾克斯
 

不过最初我试图用 $。获得,虽然服务器不得不返回大量的信息,我的浏览器没有被卡住,我可以浏览没有任何问题。

我搜索一点点网上关于它,但是我还没有100%确定对两者之间的区别。

如果 $。获得是异步的那么什么是 $点。AJAX ?如果不是,那么再见到我怎么没有导航的问题与 $。获得,有什么用 $。阿贾克斯

在此先感谢

解决方案

是的, $。获得 是异步的。从文档:

  

这是一个简写的Ajax功能,相当于:

  $。阿贾克斯({
  网址:网址,
  数据:数据,
  成功:成功,
  的dataType:数据类型
});
 

...并作为不具有异步选项,异步默认为。 (请注意,异步将完全消失jQuery中的未来版本。它的总是是真实的)

  

如果 $。获得是异步那有什么的 $。阿贾克斯

$。阿贾克斯,您可以控制​​更多的选择。 $。获得仅仅是一个捷径。

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

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.

I searched a little bit online about it, however I'm still not 100% certain about the difference between the two.

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?

thanks in advance

解决方案

Yes, $.get is asynchronous. From the documentation:

This is a shorthand Ajax function, which is equivalent to:

$.ajax({
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

...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.)

If $.get is asynchronous then what's the point of $.ajax?

$.ajax gives you control over lot more options. $.get is just a shortcut.

这篇关于为$不用彷徨的jQuery异步的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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