Loading animation doesn't show up until after ajax call completes

前端 未结 5 1942
轮回少年
轮回少年 2020-12-03 06:20

Possible duplicate: Same problem (unresolved)

I show loading DOM before the Ajax call and after the Ajax call, I hide it. For some reason, the loading image appears

5条回答
  •  长情又很酷
    2020-12-03 07:05

    The ajax() is async function and the statements under it might execute before the ajax call is completed. You have to hide in success or done function.

    $("#loading-popup").show();
    $.ajax({
    // ajax here
    }).success(data){
       $("#loading-popup").hide(0);
    })
    

提交回复
热议问题