Last active
March 27, 2020 23:29
-
-
Save zuzannamj/9992a3b95f12a73e6f4013e2bc438538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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