Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ajax load button animation

ajax load button animation

Click button, shows css animation, get html via ajax. Pretty basic, something a haven't really had an opportunity to do much, so I figured I'd try making a mock one.

A Pen by ianchouinard on CodePen.


<section class="action">
<div class="load center">
<p>Load It</p>
<div class="loader"></div>
<article class="content"></article>
function loadMe(){
$.get( '', function(data) {
//kicks things off
$('.action').on('click', '.load', function(){
//starts load animation
//sim load time and run ajax function
setTimeout(loadMe, 3000);
//restarts demo
$('.content').on('click', '.reset', function(){
.html('Load It');
<script src="//"></script>
@import url(,300);
background-color: rgb(45, 45, 45);
font-family: 'Ubuntu', sans-serif;
color: white;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
border: 4px solid rgb(225, 59, 59);
font-size: 1.2em;
cursor: pointer;
width: auto;
height: auto;
padding: .8em 1.5em;
border-radius: 0;
transition: all 500ms;
padding: .9em 1.75em;
background-color: rgba(225, 59, 59, 0.18);
width: 155px;
height: 3px;
padding: 0;
background-color: rgba(225, 59, 59, .7);
border: none;
width: 20px;
height: 3px;
background-image: linear-gradient(to right, rgba(250, 250, 250, .3), #fff);
animation: slide infinite .75s linear;
padding: 0;
background-color: rgba(225, 59, 59, .7);
@keyframes slide {
margin-left: -20px;
margin-left: 135px;
@extend .center;
text-align: center;
font-size: 1.6em;
@extend .load;
text-align: center;
margin-top: 1em;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment