求助,怎么将JS获取的JSON数据赋值到HTML页面的label中

阿滴 2015-05-16 03:21:49
刚入门,是个超级菜鸟,求高手指导指导,代码是
js代码

function InitDataGrid() {
if ($('#gdView')[0] != null) {
debugger;
var oTable = $('#gdView').dataTable({
"bJQueryUI": false,
"sDom": '<"H"CT><"F"itrp>',
"oColVis": { "buttonText": "显示隐藏列" },
"oTableTools": { "sSwfPath": "../../Scripts/TableTools-2.0.1/media/swf/copy_cvs_xls_pdf.swf", "aButtons": [{ sTableId: "gdView", "sExtends": "text", "sButtonText": "导出CVS", "fnClick": function(nButton, oConfig) { try { if (typeof (eval('Table_ExportData')) == "function") eval("Table_ExportData").call(document, nButton, oConfig); } catch (e) { alert("未实现功能"); } } }] },
"bProcessing": false,
"bServerSide": true,
"bLengthChange": false,
"iDisplayLength": PageLen, "iDisplayStart": document.getElementById(PagePrefix + '_PageNumber') == null ? 0 : document.getElementById(PagePrefix + '_PageNumber').value,
'bPaginate': true,
"bAutoWidth": true,
"bFilter": false,
"bSort": false,
"bInfo": true, "sPaginationType": "full_numbers",
"aoColumns": [
{ "sName": "Name", "sTitle": "部门/医生", "sWidth": "18%" },
{ "sName": "门诊量", "sTitle": "门诊量", "sWidth": "7%" },
{ "sName": "新诊", "sTitle": "新诊", "sWidth": "5%" },
{ "sName": "首次新诊", "sTitle": "首次新诊", "sWidth": "5%" },
{ "sName": "再次新诊", "sTitle": "再次新诊", "sWidth": "5%" },
{ "sName": "复诊", "sTitle": "复诊", "sWidth": "5%" },
{ "sName": "转入量", "sTitle": "转入量", "sWidth": "10%" },
{ "sName": "转出量", "sTitle": "转出量", "sWidth": "10%" },
{ "sName": "折前金额", "sTitle": "折前金额", "sWidth": "8%" },
{ "sName": "折扣金额", "sTitle": "折扣金额", "sWidth": "8%" },
{ "sName": "实收金额", "sTitle": "实收金额", "sWidth": "8%" },
{ "sName": "BranchId", "bVisible": false },
{ "sName": "CreateId", "bVisible": false },
{ "sName": "DepId", "bVisible": false }
],
"oLanguage": {
"sUrl": "../../Scripts/Datatables/cn.txt"
},
"sAjaxSource": "../../WebServices/VE_OutpatientReportService.asmx/GetVE_OutpatientReportList",
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
if (aData[11] != "0" && aData[12] == "0" && aData[13] == "0") {
$('td', nRow).css('background-color', '#A9F5F2');
}
if (aData[11] != "0" && aData[12] == "0" && aData[13] != "0") {
$('td', nRow).css('background-color', '#E2E1E1');
}
return nRow;
},
"fnServerData": retrieveData
});
DataTablesSetting();
}
}

function retrieveData(sSource, aoData, fnCallback) {
var thisid = $(this)[0].id;
document.getElementById(PagePrefix + '_PageNumber').value = this.fnSettings()._iDisplayStart;
Table_PushParam(aoData);
$.ajax({
type: "post",
contentType: "application/json;utf-8",
url: sSource,
dataType: 'json',
data: GetJsonParam(aoData),
success: function(data) {//这里data要怎么处理,才能将里面的想要的值提取出来
var o = eval("(" + data.d + ")"); if (o.iTotalRecords <= PageLen) { $("#" + thisid + "_wrapper .dataTables_info").hide(); $("#" + thisid + "_wrapper .dataTables_paginate").hide(); $("#" + thisid + "_wrapper .fg-toolbar").css('padding', '0'); } else { $("#" + thisid + "_wrapper .dataTables_info").show(); $("#" + thisid + "_wrapper .dataTables_paginate").show(); $("#" + thisid + "_wrapper .fg-toolbar").css('padding', '5'); } fnCallback(o);
}
});
}



...全文
674 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wish907 2015-05-19
  • 打赏
  • 举报
回复
data={"name":"小王"}; d=$.parseJSON(data); d.name就是
Go 旅城通票 2015-05-18
  • 打赏
  • 举报
回复
你的sSource webservice返回值是什么?string还是类实例?如果是类实例不需要eval,data.d就会json对象了

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧