fetch-post请求正确姿势 发表于 2017-08-18 | 分类于 前端 fetch发送post请求,不用url传参数地址栏url传参数有尺寸限制,从2k-8k不等 12345678910111213141516fetch("http://www.example.org/submit.php", { method: "POST", headers: { 'Accept': 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' }, body: "userName=&password=admin"}).then(function(res) { if (res.ok) { alert("Perfect! Your settings are saved."); } else if (res.status == 401) { alert("Oops! You are not authorized."); }}, function(e) { alert("Error submitting form!");}); 图示