Jquery ajaxStart of and ajaxStop of method of of examples

  • 2020-03-30 00:57:57
  • OfStack

JQuery provides similar functionality through the ajaxStart() and ajaxStop() methods. The ajaxStart() method is called when an Ajax request is started and there are no other Ajax requests outstanding. Again, the ajaxStop() method is called when all Ajax requests are complete. The argument to each of these methods is a function that will be called when an event occurs.

example


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title> No title page </title>
    <script src="jquery-1.4.2.min.js" type="text/javascript"></script>
      <script type="text/javascript">
        $(document).ready(function(){

         $("#Button1").click(function(){
          $.post("Default2.aspx","",function(data){
           $("#x").text(data);
          },"text");
         });
         $("#my").ajaxStart(function(){
             $(this).show();
         }).ajaxStop(function(){
           $(this).hide();
         });

        });
  </script>
</head>
<body>
    <form id="form1" runat="server">

  
    <input id="Button1" type="button" value="button"  />
    <div id="my" style=" display:none">
        <img src="loading.gif" />
    </div>
    <div id="x"></div>
    </form>
</body>
</html>


Related articles: