• JSON.stringify 在OA差旅中转换为字符串传给后端,(使用from表单的形式)


    $('#bookForm').find('#formData').val(transInfo.fromData).end().submit();

    这里的val()中的transInfo.fromData应该是字符串格式:

                                       transInfo.fromDataSec = {
                                            'arrCityCN': $('.oa-wrapper .selected .i-dest').attr('data-city'),
                                            'depCityCN': $('.oa-wrapper .selected .i-src').attr('data-city'),
                                            "goFlightInfo": JSON.stringify(transInfo.parentsInfo),
                                            "goFlightClassInfo": JSON.stringify(transInfo.childInfo),
                                            "goReasons": JSON.stringify(transInfo.checkInfo)
                                        };
                                        //transInfo.fromDataTwo = JSON.stringify(transInfo.fromDataSec);
                                        transInfo.fromDataTwo = transInfo.fromDataSec;
                                        var dataFlightSec = {
                                            'travelNO': $('.oa-wrapper .selected').attr('data-no'),
                                            'appId': APP_SHEET.appId,
                                            'depCityCN': $('.oa-wrapper .selected .i-src').attr('data-city'),
                                            'depDate': $('.oa-wrapper .selected .i-n').attr('data-date'),
                                            'arrCityCN': $('.oa-wrapper .selected .i-dest').attr('data-city'),
                                            'queryModule': 1,
                                            'showAll': $('.show-more').attr('data-flag'),
                                            "fromData": transInfo.fromDataTwo
                                        }
    
                                        var urlLInk = URL.accountPage + "?appId=" + APP_SHEET.appId + "&travelNO=" + APP_SHEET.travelNO
                                        var formTpl = '' + '<form name="bookForm" id="bookForm" action="' + urlLInk + '" method="post" >' + '<input type="hidden" id="formData" name="formData"></input>' + '</form>';
                                        $('body').append(formTpl);
                                        $('#bookForm').find('#formData').val(JSON.stringify(dataFlightSec.fromData)).end().submit();

    val()传输的数据是字符串,所以使用JSON.stringify将对象dataFlightSec.fromData转换成字符串,而dataFlightSec.fromData=transInfo.fromDataTwo= transInfo.fromDataSec是对象。

  • 相关阅读:
    lintcode:数字三角形
    lintcode:Search Insert Position 搜索插入位置
    lintcode:搜索二维矩阵II
    lintcode :搜索二维矩阵
    Linux du命令详解
    Linux df命令详解
    Linux date命令详解
    Linux tcpdump命令详解
    Linux挂载共享命令
    Linux scp命令详解
  • 原文地址:https://www.cnblogs.com/xiaozhumaopao/p/6237794.html
Copyright © 2020-2023  润新知