Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Friends,

I using the below code for deleting the list from three tables(Deleting Perfectly!). It will take hardly 10 seconds for deleting.

Here, I want to show please wait image for these waiting time..
It will show when starting the process and hide on delete process completed

JavaScript
$(document).ready(function () {
               $.ajax({
                        cache: false,
                        async: true,
                        type: "GET",
                        dataType: "json",   
                        url: "../Services/MasterServices.svc/DeleteList",
                        data: { name: vatid },
                        contentType: "application/json;charset=utf-8",
                        success: function (r) {
                            if (r != null) {
                                alert("Removed Successfully");
                            }
                        },
                        error: function (e) { alert(e.statusText); }

                    });
                });

Any help!!!

Thanks,
Karthik.J
Posted

You need to add ajaxStart() method to your code. Within this method, you can have any type of loading indicator, or changing the screens transparency etc...
JavaScript
$("yourDivOrAnyControl").ajaxStart(function(){
  $(this).html("<img src="loadingImage.gif" />");
});

So, final code would look something like,
JavaScript
$(document).ready(function () {
       $("yourDivOrAnyControl").ajaxStart(function(){
            $(this).html("<img src="loadingImage.gif" />");
       });

       $.ajax({
                cache: false,
                async: true,
                type: "GET",
                dataType: "json",   
                url: "../Services/MasterServices.svc/DeleteList",
                data: { name: vatid },
                contentType: "application/json;charset=utf-8",
                success: function (r) {
                    if (r != null) {
                        alert("Removed Successfully");
                    }
                },
                error: function (e) { alert(e.statusText); }

              });
});


For more information please see this link
http://api.jquery.com/ajaxStart/[^]
 
Share this answer
 
HTML
<span id="ajax_loading_div" style="display: inline-block;<br mode=" hold=" />    width: 150px;"></span>


JavaScript
<script type="text/javascript" language="javascript">
$(document).ready(function () {
                    $("#ajax_loading_div").addClass("loading");
                    $.ajax({
                        cache: false,
                        async: true,
                        type: "GET",
                        dataType: "json",
                        url: "../Services/FinMasterServices.svc/DeleteListCompany",
                        data: { name: vatid },

                        contentType: "application/json;charset=utf-8",
                        success: function (r) {
                            $("#ajax_loading_div").removeClass("loading");
                            if (r != null) {
                                alert("Removed Successfully");
                            }
                        },
                        error: function (e) { alert(e.statusText); }

                    });
                });
</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900