remote-form/examples/index.html

31 строка
892 B
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://unpkg.com/selector-set@latest"></script>
<script src="https://unpkg.com/@github/remote-form@latest/dist/index.umd.js"></script>
<!-- <script src="../dist/index.umd.js"></script> -->
<title>remote-form demo</title>
</head>
<body>
<form action="https://httpbin.org/get">
<label for="username" value="name">Username</label>
<input id="username" name="username" type="text" required autofocus>
<button>Submit</button>
</form>
Request payload from httpbin.org:
<pre id="results" aria-live="assertive">Empty</pre>
<script>
const input = document.querySelector('input')
remoteForm.remoteForm('form', async (form, wants) => {
const response = await wants.text()
document.getElementById('results').textContent = response.text
})
</script>
</body>
</html>