JS创建表单提交备份

 //保存
    function saveFT() {
      
        var data = {
            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) {
        //    }
        //});
    }

 

posted on 2017-06-07 11:45  花生哒哒  阅读(317)  评论(0编辑  收藏  举报

导航