0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ajaxのローディング中にくるくる(スピナー)を表示する例

Posted at

html
Click

CSS

button{

display:block;
margin:20px auto;
padding:10px 30px;
background-color:#eee;
border:solid #ccc 1px;
cursor: pointer;
}

overlay{

position: fixed;
top: 0;
z-index: 100;
width: 100%;
height:100%;
display: none;
background: rgba(0,0,0,0.6);
}
.cv-spinner {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.spinner {
width: 40px;
height: 40px;
border: 4px #ddd solid;
border-top: 4px #2e93e6 solid;
border-radius: 50%;
animation: sp-anime 0.8s infinite linear;
}
@keyframes sp-anime {
100% {
transform: rotate(360deg);
}
}
.is-hide{
display:none;
}

JS
jQuery(function($){
$(document).ajaxSend(function() {
$("#overlay").fadeIn(300); 
});

$('#button').click(function(){
$.ajax({
type: 'GET',
success: function(data){
console.log(data);
}
}).done(function() {
setTimeout(function(){
$("#overlay").fadeOut(300);
},500);
});
});
});

参考先:https://blog-and-destroy.com/7283

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?