$('#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是对象。