Created
February 4, 2021 20:23
-
-
Save kezzyhko/6bc4ae3174306ae400c3e53953e8e359 to your computer and use it in GitHub Desktop.
JS code to make POST requests and rewrite current page to the response
This file contains hidden or 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
| request = new XMLHttpRequest(); | |
| request.open("POST", "http://example.com/", true); | |
| request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | |
| request.onreadystatechange = function() { | |
| if (request.readyState == 4) { | |
| document.open(); | |
| document.write(request.responseText); | |
| document.close(); | |
| console.log("done"); | |
| } | |
| }; | |
| request.send("param=" + encodeURIComponent("value")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment