问题
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