Submit forms without a page reload. Add one header and you're done.
Point your request at your 000forms endpoint and include the Accept: application/json header. That's all — 000forms returns JSON instead of redirecting the page.
Modern and promise-based. Works natively in all current browsers — no library needed.
<form id="myForm"> <input type="text" name="name" required> <input type="email" name="email" required> <textarea name="message"></textarea> <button type="submit">Send</button> </form> <div id="status"></div>
const form = document.getElementById('myForm'); form.addEventListener('submit', async (e) => { e.preventDefault(); const res = await fetch('https://000forms.com/f/YOUR_TOKEN', { method: 'POST', headers: { 'Accept': 'application/json' }, body: new FormData(form) }); const data = await res.json(); document.getElementById('status').textContent = res.ok ? '✓ ' + data.message : '✗ ' + data.message; if (res.ok) form.reset(); });
If jQuery is already loaded in your project, you can use $.ajax() with a few key options.
$('#myForm').on('submit', function(e) { e.preventDefault(); $.ajax({ url: 'https://000forms.com/f/YOUR_TOKEN', method: 'POST', data: new FormData(this), dataType: 'json', processData: false, contentType: false, headers: { 'Accept': 'application/json' }, success: (data) => $('#status').text('✓ ' + data.message), error: (xhr) => $('#status').text('✗ ' + JSON.parse(xhr.responseText).message) }); });
Common in Vue and React projects. Handles JSON automatically and has clean error handling via try / catch.
form.addEventListener('submit', async (e) => { e.preventDefault(); try { const { data } = await axios.post( 'https://000forms.com/f/YOUR_TOKEN', new FormData(e.target), { headers: { 'Accept': 'application/json' } } ); console.log(data.message); e.target.reset(); } catch (err) { console.error(err.response?.data?.message); } });
Add these as hidden inputs inside your form to control extra behaviour. All are optional.
| Name | Description | Example value |
|---|---|---|
_subject |
Email subject line | New contact |
_redirect |
Redirect URL (non-AJAX only) | https://yoursite.com/thanks |
_cc |
CC to another address | admin@yoursite.com |
_autoresponse |
Auto-reply to the submitter | Thanks! We'll reply soon. |
_template |
Email template style | table / box / basic |
_honeypot |
Spam trap field (hide with CSS) | _honey |
When Accept: application/json is set, you always receive JSON — never a redirect.
{
"success": true,
"message": "Form submitted."
}
{
"success": false,
"message": "Validation failed",
"errors": { "email": "Required" }
}
Common patterns to improve user experience when submitting forms via AJAX.
Disable button while sending
const btn = form.querySelector('button[type="submit"]'); btn.disabled = true; btn.textContent = 'Sending…'; // re-enable inside a finally block
Send as JSON body
const payload = Object.fromEntries(new FormData(form)); fetch(url, { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
Send real requests to your endpoint and see the live JSON response instantly.
await fetch('https://000forms.com/f/YOUR_TOKEN', { method: 'POST', headers: { 'Accept': 'application/json' }, body: new FormData(form) });
$.ajax({ url: 'https://000forms.com/f/YOUR_TOKEN', method: 'POST', processData: false, contentType: false, headers: { 'Accept': 'application/json' } });
await axios.post( 'https://000forms.com/f/YOUR_TOKEN', new FormData(form), { headers: { 'Accept': 'application/json' } } );