jQuery > Ajax methods

.ajaxStart() - Register handler when 1st ajax request begins in jQuery

How to register a handler to be called when first ajax request begins in jQuery?


.ajaxStart() method is generally used when we want to show “Loading …” or “Please wait …” type of message on the web page while the ajax request is being processed.

To register a handler to be called when first ajax request begins, ajaxStart() method can be used. This can be used to show the loading… or wait …. Messages.

<script>
        $(document).ajaxStart(function () {
            $("#divAjaxStart").text("Loading ...");
            // $("#lblLoading").text("Loading.. keep patience,  have a tea and come back...");
        });
    </script>

In the above code snippet, when ajax request starts, “Loading …” is written inside “divAjaxStart” element of the page. 

 Views: 6303 | Post Order: 112



Write for us






Hosting Recommendations