您没有任何usercount变量.使用$(selector)构建一个jquery对象,您可以在其上调用
html之类的函数.
$('#userCount').html(countUsers);
另请注意
>您不需要手动将整数转换为字符串.
>如果你没有从循环中断,countUsers将始终是table.length-1.
>你有一个拼写错误:dataSet而不是数据集. Javascript区分大小写.
>您不需要解析请求的结果
>您不需要传递空数据:jQuery.post检查提供的参数的类型
因此,假设您在循环中执行其他操作,这可能更符合您的需求:
$.post("Dashboard/UsersGet", function (dataset) {
var table = dataset.Table;
var countUsers = table.length; // -1 ?
// for now, the following loop is useless
for (var i=0, i
var array = table[i];
if (array.Active == 1) { // I hope array isn't an array...
var name = array.Name; // why ? This serves to nothing
}
}
$('#userCount').html(countUsers);
});