jquery - Pass JSON Object to WCF Service getting NULL message -


i want pass json object wcf service, here service method:

    [operationcontract]     [webinvoke(method = "post",                requestformat = webmessageformat.json,                responseformat = webmessageformat.json,                bodystyle = webmessagebodystyle.wrapped)]     string insertuserdetails(userdetails userinfo);      public string insertuserdetails(userdetails userinfo)     {          return "welcome";     } 

calling jquery :

    $.ajax({       type: 'post',       url: url,       contenttype: "application/json",       data: json.stringify({ userinfo: data }),       datatype: "json",       success: function (result) {           alert(result);                   }   }); 

here getting null message in alert

this should work unless have issues in endpoint configuration. check that. not know how pass 'data' object.

below code work me.

        var serviceurl = "service.svc/insertuserdetails";         var data = new object();          $.ajax({             type: "post",             url: serviceurl,             data: json.stringify({ userinfo: data }),             contenttype: "application/json; charset=utf-8",             datatype: "json",             success: function (result) {                  alert(result);             }         }); 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -