如何使用jquery从json对象获取列表计数 [英] how to get count of list from json object using jquery

查看:118
本文介绍了如何使用jquery从json对象获取列表计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我的asp.net mvc webapi控制器返回产品列表,通过分页作为json object.by使用jquery am访问它。

我的要求是我必须返回总产品的数量,因为通过分页我一次只能回收几条记录。



建议我!!! br $> b $ b

谢谢你

解决方案

返回Json(新{结果=确定,记录=学生,TotalRecordCount = studentCount});



查看:



recordsLoaded:函数(事件,数据) {


('#tab')。html(Items(+ data.serverResponse.TotalRecordCount +));

}


我只能假设返回的JSON是一个对象数组。如果是这样,你可以在javascript中使用'length'属性获取数组的大小(而不是'count',这在js中不存在)



看到一些好的链接



Link1

链路2

Hi,

my asp.net mvc webapi controller returning list of products by paging as json object.by using jquery am accessing that.
my requirement is i have to return count of that total products,because by paging am retriving few records only at a time.

Suggest me!!!

Thank u

解决方案

return Json(new { Result = "OK", Records = students, TotalRecordCount = studentCount });

In view :

"recordsLoaded": function (event,data) {


('#tab').html("Items ("+data.serverResponse.TotalRecordCount+")");
}


I can only assume that the returned JSON is an array of objects. If so then you can get the size of the array in javascript with the 'length' property (instead of 'count', which doesn't exist in js)

See some good links

Link1
Link2


这篇关于如何使用jquery从json对象获取列表计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆