<!DOCTYPE html>
<html>
<head>
<title>AJAX Loader Example</title>
<style>
/* Styles for the loader */
.loader-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
z-index: 9999;
display: flex;
justify-content: center;
align-items: center;
backdrop-filter: blur(5px); /* Apply the blur effect */
}
.loader {
width: 40px;
height: 40px;
position: relative;
animation: spin 1s infinite linear;
}
.loader:before,
.loader:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #3498db;
transform: rotate(45deg);
transform-origin: 50% 50%;
border-radius: 50%;
opacity: 0.8;
animation: spinStar 1s infinite linear;
}
.loader:after {
background-color: #f1c40f;
opacity: 0.6;
animation-delay: 0.5s;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spinStar {
0% {
transform: scale(1) rotate(45deg);
}
25% {
transform: scale(0.6) rotate(45deg);
}
50% {
transform: scale(1) rotate(45deg);
}
75% {
transform: scale(1.4) rotate(45deg);
}
100% {
transform: scale(1) rotate(45deg);
}
}
/* Hide the loader by default */
.hidden {
display: none;
}
/* Adjust Bootstrap modal z-index */
.modal {
z-index: 1041 !important;
}
/* Adjust Bootstrap modal backdrop z-index */
.modal-backdrop {
z-index: 1040 !important;
}
</style>
</head>
<body>
<!-- Loader overlay element -->
<div id="loaderOverlay" class="loader-overlay hidden">
<div class="loader"></div>
</div>
<!-- Page content -->
<h1>Welcome to My Website</h1>
<p>This is the content of the page.</p>
<!-- Bootstrap modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal Title</h5>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>This is the modal content.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<script>
document.getElementById('loaderOverlay').classList.remove('hidden');
makeAjaxRequest('https://example.com/api/data', function(response) {
// Handle the response
document.getElementById('loaderOverlay').classList.add('hidden');
});
function makeAjaxRequest(url, callback) {
// Your AJAX implementation here
// Replace this with your own implementation using XMLHttpRequest, jQuery, Axios, etc.
}
</script>
</body>
</html>
No comments:
Post a Comment