I want to return an array of strings from an MVC function via a jQuery AJAX call.
My client side code is:
function get_categories() {
var url = "/Profile/GetCharacters";
$.post(url, function (data) {
alert(data);
});
But I cannot read array elements. In alert(data)
it always says system.array[]
and in alert(data[0])
it says s
(i.e. first character in system.array[]) and not the array elements.
Here is simplified version of my server side code.. cause original is big way too complicated :)
public Array GetCharacters()
{
var ret = new string[10];
ret[0]="abc";
ret[1] = "def";
ret[2] = "ghi";
return (ret);
}
but this gives "System.string[]" instead and same problem when accessing individual values
system.array[]
, rather than a JSON serialized array. – Virtual