首页 > 代码库 > JS创建表单提交备份
JS创建表单提交备份
//保存 function saveFT() { var data =http://www.mamicode.com/ { createDate: GetDateStr(0), name: $("#txtName").val(), gender: "未知", mobile: $("#txtTel").val(), email1: "null@null.com", interested:$("#C2 option:selected").text(), buyCarTime: "有购车计划但没决定时间", province: $("#A2 option:selected").text(), city: $("#A3 option:selected").text(), dealerName: $("#ddlDealer option:selected").text(), eventCode: "1491550852610", memo1: "2017年DAF南区3-4月促销计划", memo2: "http://design.haoche.cn/haoche/2017/4/7/fute/index.html", source: ‘好车网_PC‘ } var turnForm = document.createElement("form"); //一定要加入到body中!! document.body.appendChild(turnForm); turnForm.method = ‘post‘; turnForm.acceptCharset = "UTF-8"; turnForm.action = ‘http://www.changanfordclub.com/Media2Ford/json/CommitData.action‘; turnForm.target = ‘login2‘; turnForm.enctype = "text/json; charset=UTF-8"; //创建隐藏表单 var newElement = document.createElement("input"); newElement.setAttribute("name", "createDate"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.createDate); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "name"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.name); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "gender"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.gender); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "mobile"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.mobile); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "email1"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.email1); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "interested"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.interested); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "buyCarTime"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.buyCarTime); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "province"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.province); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "city"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.city); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "dealerName"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.dealerName); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "eventCode"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.eventCode); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "memo1"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.memo1); turnForm.appendChild(newElement); newElement = document.createElement("input"); newElement.setAttribute("name", "memo2"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.memo2); turnForm.appendChild(newElement); //新添加Source newElement = document.createElement("input"); newElement.setAttribute("name", "source"); newElement.setAttribute("type", "hidden"); newElement.setAttribute("value", data.source); turnForm.appendChild(newElement); turnForm.submit(); // $.post( // "http://www.changanfordclub.com/Media2Ford/json/CommitData.action", // data, // "json", // function (data) { // if (data.success) { // } // } //); //$.ajax({ // type: "POST", // url: "http://www.changanfordclub.com/Media2Ford/json/CommitData.action", // data: data, // dataType: "html", // cache: false, // success: function (data) { // } //}); }
JS创建表单提交备份
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。