Last active
December 19, 2017 00:34
-
-
Save RootPat/5b6b25ae1e8bd6cf8e8616de4a82bd8e to your computer and use it in GitHub Desktop.
JS function REST api call from button click
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
// javascript: | |
function ApiCall() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.open("POST", "REST URL HERE", true); | |
xhttp.setRequestHeader("Content-type", "application/json"); | |
xhttp.send(); | |
var response = JSON.parse(xhttp.responseText); | |
} | |
// Corresponding HTML button action: | |
<button type="submit" onclick="ApiCall()">Search</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment