开发者

How to constructing Javascript Array with predefined format

开发者 https://www.devze.com 2023-02-25 08:01 出处:网络
FromAJAX Call i am constructingthis data in my server {data:[{one:\"1\",two:\"2\"},{one:\"3\",two:\"3\"}]}

From AJAX Call i am constructing this data in my server

{data:[{one:"1",two:"2"},{one:"3",two:"3"}]}

I am able to access this data using data.jobs[2].one;

My question is that , is it possible to construct a similar array inside javascript also I mean this way :

var data = [{one:1,two:2},{one:开发者_JAVA技巧3,two:3}];

Please help , thank you very much


To access a value using data.jobs[2].one you would need a structure like this:

var data = {
  jobs:[
    {one:"1",two:"2"},
    {one:"3",two:"3"}
  ]
};
0

精彩评论

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