jquery - Return C# List<string> using ajax -
i have following list -
public static list<string> datanodes; then want able access using ajax -
$.ajax({ type: "post", url: "default.aspx/datanodes", success: function (data) { alert(data.d); }, error: function () { alert("error"); } }); however every time data.d undefined, there way this?
here's example start.
[webmethod] [scriptmethod(responseformat = responseformat.json)] public list<string> getdatanodes() { var datanodes = new list<string>{ "aaa", "bbbb"}; return datanodes; } then change javascript to
$.ajax({ type: "get", url: "default.asmx/getdatanodes", success: function (data) { alert(data[0]); }, error: function () { alert("error"); } }); change .aspx .asmx (service) , and should it.
Comments
Post a Comment