Show a loading bar using jQuery while making a AJAX request

前端 未结 6 1027
离开以前
离开以前 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:31

    Bootstrap Model.

           var loadingPannel;
             loadingPannel = loadingPannel || (function () {
                 var lpDialog = $("" +
                     "");
                 return {
                     show: function () {
                         lpDialog.modal('show');
                     },
                     hide: function () {
                         lpDialog.modal('hide');
                     },
    
                 };
             })();
    

    Ajax call

                        $.ajax({
                            url: "/",
                            type: "POST",
                            data: responseDetails,
                            dataType: "json",
                            traditional: true,
                            contentType: "application/json; charset=utf-8",
    
                            beforeSend: function () {
    
                                loadingPannel.show();
    
                            },
                            complete: function () {
    
                                loadingPannel.hide();
                            },
                            data: responseDetails
                        })
                        .done(function (data) {
                                if (data.status == "Success") {
    //Success code goes here
    }
    

提交回复
热议问题