【问题标题】:Want to print ajax resopnse outside of ajax function [closed]想要在ajax函数之外打印ajax响应[关闭]
【发布时间】:2022-06-13 13:45:45
【问题描述】:

this validateform function is call after button click 租约查看此链接https://datatables.net/forums/discussion/73041

函数验证表单(){ var 代码 = '0'; var from = document.rptForm.fromTime.value; var fromss = from.split("-"); var 月份 = 月份名称(fromss[1]); 变种年份 = fromss[0]; var current_date = new Date(); 从 = 从 + '00:00:00'; var to = document.rptForm.toTime.value; 到 = 到 + '23:59:59'; var e = document.rptForm.vehicalsubcode; var jsonData = '{"from":"'+from+'","to":"'+to+'"}'; jsonData = { "ReportJsonString":'[' + jsonData + ']'}; $("#rpt_table_wrapper").empty(); $('#datatableDiv div').html(''); var 数据表 = ''; 数据表 += ''; 数据表 += ''; datatable += 'DateTransaction TypeVehicle CategoryCount'; 数据表 += ''; 数据表 += ''; $(datatable).appendTo($("#datatableDiv")); if (!$.fn.DataTable.isDataTable('#rpt_table')) { $('#rpt_table').DataTable( { dom: 'Bfrtip', 固定标头:真, colReorder:真, 响应式:真实, sPaginationType: "full_numbers", bLengthChange:真, 顺序:[[ 0, 'asc' ]], aLengthMenu: [[5, 10, 15, 20, -1], [5, 10, 15, 20, , "All"]], iDisplayLength:5, aaSorting: [1, 'asc'], b处理:真, 初始化完成:函数(设置,json){ $('div.loading').remove(); }, ajax:函数(数据、回调、设置){ $.ajax({ 网址:网址", 类型:“发布”, 缓存:假, 数据:json数据, 内容类型:“应用程序/json;”, 数据类型:“json” }).done(函数(响应){ 代码=响应[0].代码; 回调({
绘制:response.draw, 数据:响应, 记录总数:响应 }); }).失败(函数(错误){ console.error('错误...', err); }); }, 按钮:[ //这些是功能 { 扩展:'pdfHtml5', title: ''+month+'-'+year的横断面明细报表, messageTop:'Code:'+ Code, // 寻找这个解决方案 messageBottom: '\n 测试, 方向:“风景”, pageSize:'合法', 文本:'导出 PDF' }, titleAttr: 'PDF' } ], 列: [ {数据:'dt'}, {数据:'txntype'}, {数据:'scat'}, {数据:'cnt'} ] }); }

        }

一切正常......但我变量“代码”会将响应数据存储到按钮 messageTop 中。

【问题讨论】:

标签: javascript ajax datatables


猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-13
  • 1970-01-01
  • 2021-12-09
  • 1970-01-01
  • 1970-01-01
  • 2020-02-29
  • 1970-01-01
相关资源
最近更新 更多