Unable to call C# method in javascript -


i want call webmethod( c# method) in aspx page in javascript ajax call. in url can pass test.aspx/mymethodname

[webmethod] [scriptmethod(usehttpget = true, responseformat = responseformat.json)] public static string loadsites() {     var jsondata = jsonconvert.serializeobject(lstsitename);     // test.visible = true; return jsondata; }  
$(document).ready(function () {            loadgrid = function () {     alert('loading grid data');     jquery("#grid").jqgrid({                    mtype: 'post',         url: 'test.aspx/loadsites',         contenttype: "application/json; charset=utf-8",         datatype: "json",         colnames: ['sitename', 'description' ],         colmodel: [                     { name: 'sitename', index: 'sitename' },                     { name: 'description', index: 'description' }         ],         sortname: "sitename",         rownum: 10,         viewrecords: true,         sortorder: "asc",         caption: "site details",         width: "auto",         height: "auto",         pager: '#pager'      });      jquery("#grid").jqgrid('navgrid', '#pager', { edit: true, add: true, del: true });  } }); 

i tried static in method didnt work well

if place attribute [webmethod] above method signature, achieve want.

furthermore, method should defined static.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -