我的代码可以正常查询php web服务并使用jQuery数据表显示结果。
问题是日期值作为[对象对象]返回。
为什么我会获得这些价值以及如何解决这些问题?
我的代码如下:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
/* Init DataTables */
$("#example").dataTable( {
"sProcessing" : true,
"sDom":'T<"clear">',
"sJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear"><"fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix"lfr>t<"fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix"ip>',
"sAjaxSource" : "Requests.php",
"sAjaxDataProp" : "",
"sDestroy" : false,
"sScrollY": "400px",
"fnServerData" : function(sSource, aoData, fnCallback) {
request = $.ajax({
"dataType" : "json",
"type" : "GET",
"url" : sSource,
"data" : aoData,
"success" : fnCallback
});
},
"aoColumns" : [
{
"mDataProp": "RequestID", "sWidth": "50px", sSortable: true,
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj)
{
// oObj.aData[0] returns the RequestID
return "<a href='details.php?RequestID="
+ oObj.aData["RequestID"] + "'> " + oObj.aData["RequestID"] + " </a>";
}
},
{ mDataProp: "RequestDate", "sWidth": "100px", sSortable: true },
{ mDataProp: "RequestorFullName", "sWidth": "150px", sSortable: true },
{ mDataProp: "PrimarySiteContactDisplay", "sWidth": "250px", sSortable: true },
{ mDataProp: "RequestLocation", "sWidth": "150px", sSortable: true },
{ mDataProp: "RequestDescription", "sWidth": "200px", sSortable: true },
{ mDataProp: "RequestStatus", "sWidth": "100px", sSortable: true },
],
})
$('#example tbody tr').click(function () {
if ($(this).hasClass('selected')) $(this).removeClass('selected');
else
{
$(this).siblings('.selected').removeClass('selected');
$(this).addClass('selected');
}
});
});
</script>
<div id="TableToolsToolbar" class="fg-buttonset ui-helper-clearfix"> </div>
<table><tr><td></td</tr></table>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;" class="display" id="cityworks">
<thead style="background-color:#DC5807; color:White; font-weight:bold;font-size:10pt;">
<tr style="border:solid 1px #000000">
<th>ID</th>
<th>Date</th>
<th>Requestor</th>
<th>Site Contact</th>
<th>Location</th>
<th>Description</th>
<th>Status</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
答案 0 :(得分:0)
我能够解决它。
我必须在服务器端将日期转换为字符串才能解决它。
convert(char(10),aa.[requestdate],101) as RequestDate
感谢大家的反馈。