JSON形式
let data = { "a" : 1 };
fetch('a.php', {
method: 'POST',
body: JSON.stringify(data),
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(res => res.json())
.catch(err => console.log(err))
.then(res => console.log(res));
表单形式
let formData = new FormData();
formData.append('b', '1');
fetch('a.php', {
method: 'post',
body: formData
}).then(res => res.json())
.catch(err => console.log(err))
.then(res => console.log(res));