Implement a loading indicator for a jQuery AJAX call

前端 未结 6 1403
我在风中等你
我在风中等你 2020-12-04 05:54

I have a Bootstrap modal which is launched from a link. For about 3 seconds it just sits there blank, while the AJAX query fetches the data from the database. How can I impl

6条回答
  •  猫巷女王i
    2020-12-04 06:19

    I'm guessing you're using jQuery.get or some other jQuery ajax function to load the modal. You can show the indicator before the ajax call, and hide it when the ajax completes. Something like

    $('#indicator').show();
    $('#someModal').get(anUrl, someData, function() { $('#indicator').hide(); });
    

提交回复
热议问题