How to perform Ajax requests, a few at a time

后端 未结 3 725
余生分开走
余生分开走 2020-12-19 06:02

I am not really sure it is possible in JavaScript, so I thought I\'d ask. :)

Say we have 100 requests to be done and want to speed things up.

What I was thin

3条回答
  •  佛祖请我去吃肉
    2020-12-19 06:35

    I'd say, the comment from Dancrumb is the "answer" to this question, but anyway...

    Current browsers do limit HTTP requests, so you can even easily just start all 100 request immediately, and the browser will take care of sending those requests as fast as possible, but limited to a decent number of parallel requests.

    So, just start them all immediately and trust on the browser.

    However, this may change in the future (the number of parallel requests that a browser sends increases as end-user internet bandwidth increases and technology advances).

    EDIT: you should also think and read about the meaning of "asynchronous" in a javascript context.. asynchronous here just means that you give up control about something to some other part of a system. so "sending" an async request just means, that you tell the browser to do so! you do not control the browser, you just tell it to send that request and please notify me about the outcome.

提交回复
热议问题