Page call:
$ ('# Btn '). click (function () {$. ajax ({type: 'post', url :'. /GridTable. aspx/call', contentType: "application/json; charset = UTF-8", data: '{"userinfo": [{"name": "zs", "age ": "21" },{ "name": "ls", "age": "25"}]} ', dataType: 'json', success: function (result) {alert (result. d) ;}}); return false ;}); backend call part. Both methods can be used.
[WebMethod] public static string call (Dictionary <string, string> [] userinfo) {System. threading. thread. sleep (5000); return str [0] ["name"];} [WebMethod] public static string test (List <UserinfoEntity> userinfos) {System. threading. thread. sleep (5000); foreach (UserinfoEntity userinfo in userinfos) {return order. rowid;} return "nothing ";}
Page call:
$ ('# Btn '). click (function () {$. ajax ({type: 'post', url :'. /GridTable. aspx/call', contentType: "application/json; charset = UTF-8", data: '{"userinfo": [{"name": "zs", "age ": "21" },{ "name": "ls", "age": "25"}]} ', dataType: 'json', success: function (result) {alert (result. d) ;}}); return false ;}); backend call part. Both methods can be used.
[WebMethod] public static string call (Dictionary <string, string> [] userinfo) {System. threading. thread. sleep (5000); return str [0] ["name"];} [WebMethod] public static string test (List <UserinfoEntity> userinfos) {System. threading. thread. sleep (5000); foreach (UserinfoEntity userinfo in userinfos) {return order. rowid;} return "nothing ";}