1. 獲取表單(form)節點app
2. 對FormData實例作相關操做spa
3. 發起HTTP請求code
function sendForm(form) { var formData = new FormData(form); formData.append('csrf', 'e69a18d7db1286040586e6da1950128c'); var xhr = new XMLHttpRequest(); xhr.open('POST', form.action, true); xhr.onload = function() { // ... }; xhr.send(formData); return false; } var form = document.querySelector('#registration'); sendForm(form);