So I have this test method in my controller, in a C# MVC Project (using razor markup):
public virtual string[] TestArray(int id)
{
string[] test = new string[] { "test1", "test2", "test3", "test4", "test5" };
return test;
}
Is there any way to get this array into javascript?
Here is what I've tried:
function testArray(id) {
$.get('Project/TestArray/' + id, function (data) {
alert(data[0]);
});
}
It goes without saying that this didn't work - I'm not great with javascript.
How can I correctly do what I'm describing?
NOTE: "Project" is the URL pattern for my Controller.