[英]I can not parse a json string with nested elements into jquery
这是JSON String的顶部,我可以提供完整的字符串,但它相当大。
{
"InspectionResultAggregate": {
"ValuationAggregate": {
"MainStreetValuation": {
"ValuationIdentifier": {
"RecordId": 2393438,
"PolicyNumber": "1143822",
"VersionId": 7005058
},
"RecordType": "INS",
"DataSource": "FIT",
"PropertyAddress": {
"Address1": "9-11 EDGEWOOD AVENUE ",
"Address2": " ",
"City": "ATTLEBORO",
"StateOrProvince": "MA",
"ZipOrPostalCode": "02703"
},
"OwnerUser": "UnknownUser",
"AssignedByUser": "PrimeVal_FIT",
"CreateDate": "2014-04-07T12:04:26.22",
"CreateUser": "PrimeVal_FIT",
"UpdateDate": "2014-04-18T12:27:00.4390372-07:00",
"UpdateStatusDate": "2014-04-07T12:04:25.433",
"UpdateUser": "PrimeVal_FIT",
"InsuredCustomer": {
"FullName": "CAROL AND TREVOR CLARKE ",
"SecondFullName": " ",
"MailingAddressSameAsPropertyAddress": true,
"MailingAddress": {
"Address1": "",
"Address2": "",
"City": ""
}
}
这是代码:无论我尝试什么,我都不能将policynumber分配给var p。
// CALCULATE VALUE
$('#calculate').click(function () {
$('#general_message').text('Calculating...').fadeIn(1);
dataString = $('form').serialize();
$.ajax({
type: "POST",
url: "ajax_submit_soap_request.php",
data: dataString,
datatype: 'json',
success: function (data) {
alert(data);
$('#general_message').text('Calculation Finished!').fadeOut(3000);
var p = data.InspectionResultAggregate.ValuationAggregate.MainStreetValuation.ValuationIdentifier.PolicyNumber;
$('#policy').text(p);
}
});
return false;
})
您尝试使用datatype
设置dat datatype
,它应该是dataType
dataType: 'json',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.