(Medium) - Commands And Events
This article is too short to generate a summary.
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
| <div id="content"> | |
| <form method="POST" action="http://server.example.com/"> | |
| <input type="text" name="username"> | |
| <input type="submit" value="Send POST command with username"> | |
| <input type="button" onclick="submitUsername()" value="Send POST command with username using AJAX"> | |
| </form> | |
| </div> | |
| <script> | |
| function submitUsername() { | |
| return fetch('http://server.example.com', { method: 'POST' }) | |
| .then((response) => { response.text() }) | |
| .then((responseBody) => { | |
| document.getElementById('content').innerHTML = responseBody; | |
| }); | |
| } | |
| </script> |
Report this article
Tell us what's wrong. Every field is optional.