Home >Web Front-end >JS Tutorial >jQuery simply implements the method of submitting data and showing loading progress bar_jquery

jQuery simply implements the method of submitting data and showing loading progress bar_jquery

WBOY
WBOYOriginal
2016-05-16 15:07:492026browse

The example in this article describes how jQuery simply implements a loading progress bar when submitting data. Share it with everyone for your reference, the details are as follows:

The html part of the code is as follows, copy and import the class library to use

<html>
<head>
<style type="text/css">
 #bg{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.2; opacity:.2; filter: alpha(opacity=70);}
 .loading{display: none; position: absolute; top: 50%; left: 50%; z-index:1002; }
 </style>
</head>
<body>
  <div id="bg"></div>
  <input type="button" value="Save" id="btnSave" name="btnSave" />
  <div class="loading"><img src="loading.gif"></div>
</body>
</html>

Part of the jQuery code is as follows:

<script src="jquery-1.11.0.min.js" type="text/javascript"></script><!--自己下载类库-->
<script type="text/javascript">
$(function(){
  $("#btnSave").click(function(){
    $("#bg,.loading").show();
    $.ajax({
      async:false,
      url:"time.php",
      type:"post",
      data:{},
      success:function(mes){
        $("#bg,.loading").show();
      }
    })
  })
})
</script>

php code:

for($i=0;$i<10000000;$i++){
}

Readers who are interested in more jQuery related content can check out the special topics on this site: "JQuery switching effects and techniques summary", "jQuery drag effects and techniques summary", "JQuery extension skills summary", "jQuery common classic special effects summary", "jQuery animation and special effects usage summary", "jquery selector usage Summary " and "Summary of jQuery common plug-ins and usage "

I hope this article will be helpful to everyone in jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn