gpt4 book ai didi

javascript - 我无法将带有嵌套元素的 json 字符串解析为 jquery

转载 作者:行者123 更新时间:2023-12-02 17:29:57 25 4
gpt4 key购买 nike

这是 JSON 字符串的顶部部分,我可以提供完整的字符串,但它相当大。

{
"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": ""
}
}

这是代码:无论我如何尝试,我都无法将策略编号分配给 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设置数据类型,而它应该是dataType

dataType: 'json',

关于javascript - 我无法将带有嵌套元素的 json 字符串解析为 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23161616/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com