📜  fetch 方法 post 处理 post add on php - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:16.383000             🧑  作者: Mango

代码示例1
// if you are going to use post method you need to send the data/body  using the formdata object
var url = '/your/url';
var formData = new FormData();
formData.append('x', 'hello');

fetch(url, { method: 'POST', body: formData })
.then(function (response) {
  return response.text();
})
.then(function (body) {
  console.log(body);
});