C# 我想使用angularjs将数据表传递给wcf服务
以下是我使用datatable请求的wcf服务:C# 我想使用angularjs将数据表传递给wcf服务,c#,json,angularjs,wcf,C#,Json,Angularjs,Wcf,以下是我使用datatable请求的wcf服务: [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "/checkout", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessa
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "/checkout",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
void Checkout(UserDetails data);
这是我的客户端代码:
$scope.checkout = function () {
var data = {
"MemberID": "2500394300",
"CategoryID": "1",
"ProductID": "1",
"PointValue": "100"
};
$http.post(
"url",
data,
{
headers: {
'Content-Type': 'application/json'
}
}
).success(function (result) {
alert(result);
});
}
您应该将
数据
变量转换为JSON字符串:
$http.post(
"url",
JSON.stringify(data)
为了便于使用,您应该使用json数据。