Home > Web Front-end > JS Tutorial > jQuery Ajax displays loading animation asynchronously when loading data

jQuery Ajax displays loading animation asynchronously when loading data

高洛峰
Release: 2016-12-28 11:04:21
Original
2004 people have browsed it

I won’t go into details about ajax loading background data.

Look at the code below and first place the code on the front desk

<div id="loadgif" style="width:66px;height:66px;position:absolute;top:50%;left:50%;">
  <img alt="加载中..." src="../../Images/loading1.gif"/>
</div>
Copy after login

First hide the image animation in the js script file

The code is as follows

$(document).ready(function () { $("#loadgif").hide();});
Copy after login

Then the asynchronous ajax submission request code is as follows

$(function () {
var find = new Find();
//alert(find.Template);
$.ajaxSetup({
cache: false,
async: true,
global: false,
type: "POST"
});
$("#queryBtn").click(function () { $("#loadgif").show(); find.Get() });
Copy after login

... .............

Note:

async: true,

When the queryBtn button is clicked When the time comes, call the animation display

$("#loadgif").show();
Copy after login

Then submit the request

Wait until the request is received

$("#loadgif").hide();
Copy after login

The effect is as follows:

jQuery Ajax 加载数据时异步显示加载动画

The above is the jQuery Ajax asynchronous display loading animation introduced by the editor when loading data. I hope it will be helpful to everyone. For help, if you have any questions please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!

For more jQuery Ajax asynchronous display of loading animation when loading data, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template