Show a loading bar using jQuery while making a AJAX request

前端 未结 6 1088
离开以前
离开以前 2021-01-03 01:40

I\'m making a AJAX request with jquery like:

$.get(\'/Stuff.php\', function (data) {
    $(\'#own\').html(data);
});

while this data is loa

6条回答
  •  不知归路
    2021-01-03 02:19

    use the ajaxSetup

    $.ajaxSetup({
        beforeSend:function(xmlHttpRequest){
        //show the loading div here
        },
        complete:function(){
    
        //remove the div here
        }
        });
    

    now make the ajax call

    $.get('/Stuff.php', function (data) {
        $('#own').html(data);
    });
    

提交回复
热议问题