这是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;
})
答案 0 :(得分:2)
您尝试使用datatype
设置数据类型,应该是dataType
dataType: 'json',