在我的控制器中,我正在调用网络服务
Metadata.Client.Service.Client returnClient = new Metadata.Client.Service.Client();
returnClient = client.UpdateClient(updateClient);
return Json(new { returnClient }, JsonRequestBehavior.AllowGet);
在我的 .cshtml Ajax 调用中,如下所示
$.ajax(
{
type: "GET",
contentType: "application/json; charset=utf-8",
url: '@Url.Action("UpdateRecord", "Client")',
data: { "id": id, "name": clientName, "code": clientCode, "typeId": clientTypeId, "clientStatusCode": clientStatusCode },
dataType: "json",
beforeSend: function () {//alert(id);
},
error: function (request) {
alert('error');
alert(request.responseText);
},
success: function (data) {
alert('success');
console.log(data);
//var parsed = JSON.parse(data);
//alert(parsed);
//var k = JSON.stringify(data);
//alert(parsed);
}
我尝试了几种方法来提取数据。在console.log
它显示如下
[09:27:07.989] ({returnClient:{ExtensionData:{}, ClientCode:"C09091", ClientId:39, ClientName:"Test1", ClientStatus:[{ExtensionData:{}, StatusCode:{ExtensionData:{}, Name:"Active", StatusCodeId:5}, StatusType:{ExtensionData:{}, Name:"OE", StatusTypeId:1}}], ClientType:{ExtensionData:{}, ClientTypeId:7, ClientTypeName:"FDFD"}}})
请任何人都可以帮助提取这些数据
IE,ClientName, ClientCode, ClientId, ClientStatus.StatusCode, ClientStatus.Name, ClientStatus.StatusCodeId, StatusType.Name