[点晴永久免费OA]html用隐藏iframe做提交保存,似乎是url太长,变成404了
当前位置:点晴教程→点晴OA办公管理信息系统
→『 经验分享&问题答疑 』
:html用隐藏iframe做提交保存,似乎是url太长,变成404了 错误的方式(会导致 404)
正确的隐藏 iframe POST 方式
对于现代项目,强烈推荐直接使用 javascript fetch('/api/save', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ content: longText }) }).then(res => res.text()).then(console.log); 使用 URL 编码格式 (x-www-form-urlencoded) javascript const longText = document.getElementById('longData').value; // 将数据编码为 query string 格式 const encodedData = new URLSearchParams(); encodedData.append('content', longText); fetch('/api/save', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: encodedData // 结果是 "content=...&..." }) .then(response => response.text()) .then(data => console.log(data)); 该文章在 2026/7/1 9:12:18 编辑过 |
关键字查询
相关文章
正在查询... |