Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Last active March 27, 2020 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zuzannamj/9992a3b95f12a73e6f4013e2bc438538 to your computer and use it in GitHub Desktop.
Save zuzannamj/9992a3b95f12a73e6f4013e2bc438538 to your computer and use it in GitHub Desktop.
<script>
function showSpinner() {
$spinner = document.getElementsByClassName("slds-spinner_container")[0];
$spinner.style.display = "block";
}
function hideSpinner() {
$spinner.style.display = "none";
}
...
function postData() {
fetch("http://example.com/myData.json", {
method: "POST",
headers: {
...
},
body: ({
...
})
}).then(function(res) {
hideSpinner(), window.alert("Success")
}).catch(function(err) {
hideSpinner(), window.alert("Error")
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment