0

I am calling webmethod in order to return string array in jquery. Regular one dimension string array looks like this

[WebMethod]
public static string[] GetNewRow() {
    var listOfItems = new List<string>();
    // populate the listOfItems here
    listOfItems.Add("100");
    // more here
    return listOfItems.ToArray();
}

Is it possible to return a multidimensional array?

mko
  • 6,638
  • 12
  • 67
  • 118
  • 1
    Can you show what structure would be ideal? Is it really just a [][]? – Joe Nov 03 '11 at 20:49
  • Any structured acceptable by jquery. I tried returning multidimensional string (string[,]), but in jquery it is treated as a single dimensional array. I would like to reference it with two params [a][b] if possible – mko Nov 03 '11 at 20:53

1 Answers1

0

an array ( [] ), in javascript, is numerically indexed. You have to use an object ( {} ) to access it with a named index. the following example is valid in javascript

var thing = { a: {'b': 10}};
thing.a['b'] = thing['a'].b + thing['a']['b'] * thing.a.b;

you might get info on JSON object, and a function "object_to_json" on your server side language. check this link for java, or json_encode for php.

Community
  • 1
  • 1
roselan
  • 3,755
  • 1
  • 20
  • 20