Pages

Sunday, May 22, 2011

Example for jQuery AJAX post

<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
<script>
   $(document).ready(function(){
        $("#loading").ajaxStart(function(){
   $(this).show();
 });
        $.ajax({
   type: "POST",
   url: "some.php",
   data: "name=John&location=Boston",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });

$("#loading").ajaxStop(function(){
      $(this).hide();
      });

   });
</script>

<div id="loading" style="display: none;">Loading...</div>

No comments:

Post a Comment