1. 获取表单(form)节点

2. 对FormData实例做相关操作

3. 发起HTTP请求

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);
05-23 22:48