Friday, 23 November 2012

Show Loading Image on AJAX enabled WCF Service

The below code is used to Show Loading Image on AJAX enabled WCF Service when 
the service is processing the service.
 
<span id="ajax_loading_div" style="display: inline-block;
 width: 150px;"></span>
 
<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/Services.svc/DeleteList",
                        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>

No comments:

Post a Comment