What's the difference between : 1. (ajaxStart and ajaxSend) and 2. (ajaxStop and ajaxComplete)?

后端 未结 1 1957
难免孤独
难免孤独 2020-12-05 09:53

Basically that\'s the question (parentheses are important)

相关标签:
1条回答
  • 2020-12-05 10:40

    .ajaxStart() and .ajaxStop() are for all requests together, ajaxStart fires when the first simultaneous request starts, ajaxStop fires then the last of that simultaneous batch finishes.

    So say you're making 3 requests all at once, ajaxStart() fires when the first starts, ajaxStop() fires when the last one (they don't necessarily finish in order) comes back.

    These events don't get any arguments because they're for a batch of requests:

    .ajaxStart( handler() )
    .ajaxStop( handler() )
    

    .ajaxSend() and .ajaxComplete() fire once per request as they send/complete. This is why these handlers are passed arguments and the global/batch ones are not:

    .ajaxSend( handler(event, XMLHttpRequest, ajaxOptions) )
    .ajaxComplete( handler(event, XMLHttpRequest, ajaxOptions) )
    

    For a single documentation source, the Global Ajax Events section of the API is what you're after.

    0 讨论(0)
提交回复
热议问题