在线请教调用Jquery错误:TypeError: a is undefined 的错误原因有哪些?
请教:后台通过ashx生成json字符串的递归树,json字符串在线验证格式正确;但总是jquery错误如下,请问什么原因呢?
TypeError: a is undefined
调用的js代码:
function InitLeftMenu() {
$("#nav").accordion({ animate: true });
var filename = '/ashx/SysModuleHandler.ashx';
// PageAjaxCall(filename, {}, function (rsp) {
$.getJSON('ashx/SysModuleHandler.ashx', function (r) {
$.each(rsp.menus, function (i, n) {
var menulist = '';
menulist += '<ul>';
$.each(n.menus, function (j, o) {
menulist += '<li><div><a ref="' + o.menuid + '" href="javascript:void(0)" rel="' + o.url + '" ><span class="' + o.icon + '" > </span><span class="nav">' + o.menuname + '</span></a></div></li> ';
})
menulist += '</ul>';
cosole.info(menulist);
$('#nav').accordion('add', {
title: n.menuname,
content: menulist,
iconCls: n.icon
});
});
Json字符串:
{
"menus": [
{
"menuid": "5",
"icon": "icon icon-sys",
"menuname": "任务管理"
},
{
"menuid": "1",
"icon": "icon icon-sys",
"menuname": "系统管理",
"menus": [
{
"menuid": "4",
"menuname": "权限管理",
"icon": "icon icon-sys",
"url": "#"
},
{
"menuid": "3",
"menuname": "角色管理",
"icon": "icon icon-sys",
"url": "#"
},
{
"menuid": "2",
"menuname": "用户管理",
"icon": "icon icon-sys",
"url": "#"
}
]
}
]
}
------解决方案--------------------
JScript code
// PageAjaxCall(filename, {}, function (rsp) {
$.getJSON('ashx/SysModuleHandler.ashx', function (r) {
$.each(rsp.menus, function (i, n) {