.modal {
display: none;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba( 255, 255, 255, .8) url('https://i.stack.imgur.com/FhHRx.gif') 50% 50% no-repeat;
}
/* When the body has the loading class, we turn
the scrollbar off with overflow:hidden */
body.loading {
overflow: hidden;
}
/* Anytime the body has the loading class, our
modal element will be visible */
body.loading .modal {
display: block;
}
JavaScript
$body = $("body");
$(document).on({
ajaxStart: function() {
console.log("ajax started");
$body.addClass("loading");
},
ajaxStop: function() {
$body.removeClass("loading");
}
});
$(function() {
$('form').submit(function() {
var temporaryTimeOut = 10000;
$.ajax({
url: "http://localhost/xmlString", //Url,
type: 'POST',
crossDomain: true,
dataType: 'jsonp',
reTry: 1, //setRetry,
timeout: 10000, //setTimeOut,
success: function(response) {
var maximumUsers = 4;
if (2 != maximumUsers) {
var dialog = confirm("Add another User?");
if (dialog == true) {
window.location.href = "userDetails.html";
} else {
window.location.href = "usersList.html";
}
} else {
alert("Maximum users limit of " + maximumUsers + " has been reached");
window.location.href = "usersList.html";
}
alert(serverResponse + "\nData saved successfully");
return;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus === "timeout") {
alert("Server connectivity error! Pls check your internet connection");
var maximumUsers = 4;
if (2 != maximumUsers) {
var dialog = confirm("Add another User?");
if (dialog == true) {
window.location.href = "userDetails.html";
} else {
window.location.href = "usersList.html";
}
} else {
alert("Maximum users limit of " + maximumUsers + " has been reached");
window.location.href = "usersList.html";
}
}
}
});
return false;
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.