Javascript can read the list using for loop. e.g
[WebMethod]
public static List<EmpName> GetData(int startIndex, int maximumRows, string sort, string filter)
{
var emp = objClient.GetData(startIndex, maximum开发者_高级运维Rows, sort, filter);
List<EmpName> lstEmp = new List<EmpName>();
foreach (var item in emp)
{
EmpName objEmp = new EmpName();
objEmp.ID = item.ID;
objEmp.Name = item.Name;
lstEmp.Add(objEmp);
}
return lstEmp;
}
Javascript:
function ReadList(lstEmp)
{
for(var i=0;i<lstEmp.length;i++)
{
alert(lstEmp[i].ID+" "+ lstEmp[i].Name);
}
}
I want to create a list in javascript i.e List to perform various operation at client side how it can be achieved?
There are multiple ways to create a List in JS.
The easiest one being
var l = [];
l[0] = "a";
l[1] = 1;
another way todo so is
var l= [1,"as",func];
refer W3Schools
精彩评论