firebug (1.10.1) suggests javascript is not confined to a single thread in firefox (13.0)

前端 未结 3 806
攒了一身酷
攒了一身酷 2021-01-22 00:46

While debugging some client side javascript today in Firefox, I ran into something that I found quite odd and little unnerving. Also, I was unable to duplicate this behavior wh

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-22 01:00

    $.get("http://google.com/") is asynchronous, it is a race on what gets done first. The first time it is slower since it needs to make the call and the call happens later in the code execution. The call is already cached with the second request, so it happens to execute quicker.

    If you need something to be done before the request goes out use beforeSend().

提交回复
热议问题