开发者

Ajax enabled webservice returns a list, how JS understand a list?

开发者 https://www.devze.com 2023-03-28 08:12 出处:网络
I was asked a question in an interview, not sure if it was a trick question or not. Ajax enabled webservice in c# returns a list, how does javascript understand list? How will you bind it to grid?

I was asked a question in an interview, not sure if it was a trick question or not.

Ajax enabled webservice in c# returns a list, how does javascript understand list? How will you bind it to grid?

I guess he was asking about the Arra开发者_开发百科yList as I know webservice (.asmx) method can't return List. Appreciate if someone can give an example on how can I use Javascript to populate the list into grid.


He's probably referring to an JSON object or in this case an array. JSON is the common language used when using AJAX.

A JSON object has the form:

{ fieldOne: "hello", fieldTwo:"world" }

A JSON Array has the form:

[
{ fieldOne: "hello", fieldTwo:"world" },
{ fieldOne: "hello2", fieldTwo:"world2" },
]

So you can see that this might well be applied to a data table/grid.

0

精彩评论

暂无评论...
验证码 换一张
取 消