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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -