当前位置:网站首页>JS simulation form post submission
JS simulation form post submission
2022-07-22 11:03:00 【User 9914333】
scene : Need to submit data , And after data processing , Will jump to the page .( notes : Data submission requires post) Ideas 1: 1. Reference resources ajax Submit data , To deal with , After successful processing, return to the client 2. Jump to the page on the client Ideas 2: Use form Form proceed post Submit Implementation method : You need to create a form form , And the data must be in form In the table , use Input Save the table elements , The effect is as follows :
/// form Form submission
var form2 = document.createElement("form");
form2.id="form2";
form2.method="post";
form2.action="buildOrder.do";
// Address id
var address = document.createElement("input");
address.name="addressId";
address.type="hidden";
address.value = orderAddressId;
form2.appendChild(address);
// The shopping cart id
var sid = document.createElement("input");
sid.name="sid";
sid.type="hidden";
sid.value = shopCartId;
form2.appendChild(sid);
// The total price
var total = document.createElement("input");
total.name="total";
total.type="hidden";
total.value = $("#labTotalMoney").text();
form2.appendChild(total);
document.body.appendChild(form2);
form2.submit(); // Submit
notes : Remember to add
document.body.appendChild(form2); above form Method of submission , I feel it's still too troublesome to transmit data , Must be written as form The elements of the form , I wonder if there is a simpler way , Please give advice or comments
边栏推荐
- What is a video content recommendation engine?
- 2022 音视频技术风向标
- 利用西门子低代码实现企业质量管理流程的敏捷性
- : empty pseudo class replaces JS to realize the prompt when it is empty
- 你真的会使用搜索引擎吗?
- 【10点公开课】:云视频会议系统私有化实践
- js 模拟form表单post提交
- 向量化引擎对HTAP的价值与技术思考
- Robot modeling and 3D simulation based on ROS [physical / mechanical significance]
- 服裝ERP上線後,這些問題必須重視
猜你喜欢
随机推荐
面试复盘四
TCP 通信并发服务器详解(附有案例代码)
2022 audio and video technology vane
Seven best ways to overcome procrastination
[10:00 public class]: cloud video conference system privatization practice
Interview difficulties: difficulties in implementing distributed session, this is enough!
2022-7-21 the seventh group of Pan Xiaotang inheritance and super and this
【云原生 | 从零开始学Kubernetes】七、资源清单与Namespace
计网--传输层
Response redirection
禅道的使用
Reproduce pytorch version from zero (3)
字符集和比较规则的应用
炒股开户哪家证券好 网上开户安全吗
C # realize the conversion of Chinese characters to Pinyin
[red team] att & CK - active scanning
数据分析从0到1----Matplotlib篇
Response response byte data
企业源代码防泄密工作该如何开展
基于ROS的机器人模型建立及3D仿真【物理/机械意义】