fill datatable with json and web service

非 Y 不嫁゛ 提交于 2019-12-12 05:51:56

问题


i need to display the data in a table in client side call,so i need to fill the datatable and show it into table view,just check my code whether i need to include any min file or change any code,help me. my client side code

<script src="Scripts/jquery1.11.1.js" type="text/javascript"></script>
<script src="Scripts/jquerydatable1.10.2.js" type="text/javascript"></script>
<script src="Scripts/display_cusdetail_jqgrid.js" type="text/javascript"></script>
  </head>
 <body>
<form id="form1" runat="server">
  <div>
    <b>customer details</b>
      <input type="button" id="button1" value="clickme" />
  <div id="divformytable">
   <table id="tablename">   
      <tr>
      <td>
      </td>
      </tr> 
    </table>  
   </div></div></form></body>

my script file:display_cusdetail_jqgrid.js

        $(document).ready(function () {
       $("#button1").click(function (event) {
    $.ajax({
        type: "POST",
        url: "Name.asmx/Display",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: AjaxSucceeded,
        error: AjaxFailed
       });
       });
      });
      function AjaxSucceeded(result) {
         alert("hi");
         if (result.hasOwnProperty("d")) {
          result = result.d;
             }
         //  var data = jQuery.parseJSON(result);
         $('#divformytable').html('<table cellpadding="0" cellspacing="0" border="0"          id="tablename" class="style1 datatable"></table>');
         $('#tablename').dataTable({
            "bPaginate": true,
           "sPaginationType": "full_numbers",
             "bAutoWidth": true,
             "bJQueryUI": false,
             "bLengthChange": true,
           //"fnRowCallback": customFnRowCallback,
            "aaData": aaData,
             "aoColumns": [
               //Assign the data to rows
   {"mDataProp": "eid", "sTitle": "0", "bSearchable": false, "bVisible": true },
   { "mDataProp": "ename", "sTitle": "1", "bSearchable": false, "bVisible": true  },
   { "mDataProp": "dob", "sTitle": "2", "bSearchable": false, "bVisible": true },
   { "mDataProp": "addr", "sTitle": "3", "bSearchable": false, "bVisible": true },
   { "mDataProp": "pincode", "sTitle": "4", "bSearchable": false, "bVisible": true },
   { "mDataProp": "dsgid", "sTitle": "5", "bSearchable": false, "bVisible": true },
   { "mDataProp": "salary", "sTitle": "6", "bSearchable": false, "bVisible": true},     {"mDataProp": "doj", "sTitle": "7", "bSearchable": false, "bVisible": true }
             ]
            });
             }

when i run this its shows error in this line aaData:aaData is undefined, any one help me

来源:https://stackoverflow.com/questions/25638987/fill-datatable-with-json-and-web-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!