数据表Jquery动态填充

时间:2016-04-25 04:56:26

标签: javascript php jquery datatables

我在我的一个项目中使用DataTables,我必须在其中填写Oracle查询结果。我指的是this document

问题:

查询返回的所有10列都显示在表的第1行第1列中。

的Javascript

$('#inquiryForm').submit(function(){    
    var cnic = "data="+ $( "#cnicInd" ).val();
    //alert(cnic);

     $.ajax({
    type: "POST",
    url: "php/inquiryInd.php",
    data: cnic,
    success: function(datapage) {
          //$("#errmsg").html(data).show();
          var datacopy = [[datapage]]; 

    prompt("Result",datacopy);
     $('#dataTables-example').DataTable({   
            responsive: true,
            "data": datacopy,
             columns: [
        { title: "Policy No." },
        { title: "Client Name" },
        { title: "Gross Premium" },
        { title: "Next Due Date" },
        { title: "Commencement Date" },
        { title: "Cash Value" },
        { title: "Total Amount Paid" },
        { title: "Total Amount Due" },
        { title: "Total unconsumed Amount" },
        { title: "Status" }
    ]

    });

    }
   });

     $('#searchTable').show();
        return false;               
    });

inquiryInd.php

while (($row = oci_fetch_array($stmnt)) != false) {

$result = "";

$result .= '"'.$row['PROPOSAL']."\"";
$result .= ',"'.$row['FULLNAME']."\"";
$result .= ',"'.$row['GROSSPREMIUM']."\"";
$result .= ',"'.$row['NEXTDUEDAT']."\"";
$result .= ',"'.$row['COMMENDATE']."\"";
$result .= ',"'.$row['CASH_VALUE']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_PAID']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_DUE']."\"";
$result .= ',"'.$row['TOTAL_AMOUNT_DUE']."\"";
$result .= ',"'.$row['STATUS']."\"";
//$result .= ']';
$dataset .= $result;

//Something like  "Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800" 
}

请让我知道我做错了什么。任何帮助将受到高度赞赏。

0 个答案:

没有答案