c# - Passing GUID to WebMethod from jQuery -


i have jquery function calling c# webmethod. i'm trying pass guid webmethod keep receiving error. detail i'm getting input string not formatted correctly.

the guid passed jquery function string. passed webmethod via post data. saved database string in field nvarchar(max).

my jquery function looks this:

function savelike(id_in) {      var jsontext = json.stringify({ id: id_in });     var lblid = "#lbllike" + id_in;      $.ajax({         type: "post",         url: "http://test.mainehousing.org/services/activityfeedservice.aspx/savelike",         contenttype: "application/json; charset=utf-8",         datatype: "json",         data: jsontext,         success: function (msg) {             $(lblid).text(msg.d);         },         error: function (xhr, status, error) {             alert(error);         }     }); } 

and c# webmethod looks this:

[system.web.services.webmethod()]     public static string savelike(string id_in)     {         //         activityfeed.clsfeed objaf = new activityfeed.clsfeed();         activityfeed.clsfeeds objafs = new activityfeed.clsfeeds();         int i;         string olikes = "";         string ostr;          objaf = new activityfeed.clsfeed();         objaf.subfeeditemid = id_in;         objaf.subfeedemployeeid = httpcontext.current.session["globalempid"].tostring();         objaf.subfeedindicatorid = 1;         objaf.subfeedcomment = "";         objaf.subfeeditemdate = datetime.now;         objaf.saveactivityfeedlike();     } 

i've been trying figure out days , stumped. have ideas? appreciated.

thanks amanda

btw c# error or ajax error? issue noticed name of web method parameter... hope web method should following

[system.web.services.webmethod()] public static string savelike(string id) {     //     activityfeed.clsfeed objaf = new activityfeed.clsfeed();     activityfeed.clsfeeds objafs = new activityfeed.clsfeeds();     int i;     string olikes = "";     string ostr;      objaf = new activityfeed.clsfeed();     objaf.subfeeditemid = id_in;     objaf.subfeedemployeeid = httpcontext.current.session["globalempid"].tostring();     objaf.subfeedindicatorid = 1;     objaf.subfeedcomment = "";     objaf.subfeeditemdate = datetime.now;     objaf.saveactivityfeedlike(); } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -