How to use ajaxStart() Method in JQuery AJAX

In this article, I will explain use of ajaxStart() Method in JQuery AJAX.
  • 2810

JQuery AJAX ajaxStart() Method

  • ajaxStart() method add a function to be execute when an AJAX request begins and already active.

  • ajaxStart() method is a AJAX Event.

Syntax

$(selector).ajaxStart(function())

  • function()  The function is run when the request is start.

Example

 

The following example show the use of ajaxStart() method.

 

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("div").ajaxStart(function () {

            $(this).html("<img src='demo_wait.gif' />");

        });

        $("button").click(function () {

            $("div").load("demo_ajax_load.asp");

        });

    });

</script>

</head>

<body>

<div><h2>ajaxStart() Method Example</h2></div>

<button>Click</button>

</body>

</html>

Output

start.jpg 

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2013 dotNetheaven. All rights reserved.