异步和同步 [英] Asynchronous and synchronous

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

问题描述

如果我用在同一页上的同步和异步Ajax请求页面时,将在浏览器加载以及同步的要求是第一和异步是页面上第二个请求。那么会发生什么呢?

IF I used synchronous and asynchronous ajax request on the same page when page will load on browser and synchronous request is first and asynchronous is second request on page. So what will be happen there?


  1. 将异步请求等到同步请求从服务器获取数据。

  1. will Asynchronous request wait until synchronous request will get the data from the server.

或将异步请求不会等待并执行的请求?

Or will Asynchronous request not wait and execute as the request?

我试图找到这个答案,但没有取得任何进展。请给答案,如果任何人有

I tried to find this answer but didn't get anywhere. Please give the answer if anyone have

推荐答案

同步意味着code,直到请求完成发起的同步请求等待和块。主叫和被叫code是的同步的。异步意味着code发起请求立即继续和异步调用会晚些时候完成。主叫和被叫code是的不同步异步

Synchronous means that the code that initiates the synchronous requests waits and blocks until the request completes. The calling and the called code are "in sync". Asynchronous means the code that initiates the request continues immediately and the asynchronous call will complete sometime later. The calling and the called code are "not in sync" or asynchronous.

因此​​,如果你的code类火灾同步请求,它会等待,直到该请求完成。直到同步一个操作完成闲来无事将在此期间发生,因此异步请求不会被触发。

As such, if your code fires a synchronous request, it waits until that request is completed. Nothing else will happen in the meantime, so the asynchronous request won't be triggered until the synchronous one completes.

如果你火异步请求第一和事后同步的,它并不一定清楚哪些code将完成/执行第一,因为异步请求可在任何时间完成。

If you fire the asynchronous request first and the synchronous one afterwards, it's not necessarily clear which code will finish/execute first, since the asynchronous request may finish at any time.

这篇关于异步和同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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