weixin_33726318 2014-11-24 10:50 采纳率: 0%
浏览 22

如何在Ajax中使用数据表

I want to try pagination using datatables.net via ajax.

I have 2 input fields which sends start date and end date and following is the table structure

<table class="table table-hover" id="example">
              <thead>
          <tr>
          <th>Loan ID</th>
            <th>Date</th>
            <th>Loan Amount</th>
            <th>Loan Type</th>


          </tr>
        </thead>
        <tbody id="amount"></tbody></table>

when the button is clicked,I am calling this function

$('#recv').click(function(){
      var fromDate=$('#from').val();
      var toDate=$('#to').val();

      var test=$.ajax({
          type: "GET", 
           url: "/project/getDetails",  
              data:{"fromDate":fromDate,"toDate":toDate},
              dataType:"json",async:false 
      }).responseText;
      var result = eval('('+test+')');
      $('#example').dataTable( {
          "bServerSide": true,
            "sAjaxSource": result,
            "bProcessing": true,
            "aoColumns": [
                            { "sName": "Loan_ID",
                                "bSearchable": false,
                                "bSortable": false

                            },
                            { "sName": "Date" },
                            { "sName": "Loan_Amount" },
                            { "sName": "Loan_Type" }
                        ]
        } );

When Ever I click on the button then I get error in alert box saying datatables warning id=example ajax error

Can anybody please tell me how to solve?

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错