我想将 JSON 对象传递给 WCF 服务,这是我的服务方法:
[OperationContract]
[WebInvoke(Method = "POST",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
string InsertUserDetails(UserDetails userInfo);
public string InsertUserDetails(UserDetails userInfo)
{
return "welcome";
}
从 jquery 调用:
$.ajax({
type: 'POST',
url: url,
contentType: "application/json",
data: JSON.stringify({ userInfo: data }),
dataType: "json",
success: function (result) {
alert(result);
}
});
在这里,我在警报中收到 NULL 消息