首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我无法将带有嵌套元素的json字符串解析为jquery。

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

Stack Overflow用户
提问于 2014-04-18 20:16:12
回答 1查看 57关注 0票数 0

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

代码语言:javascript
复制
{
    "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。

代码语言:javascript
复制
// 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;
})
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-18 20:22:50

您尝试用datatype设置dat类型,而它应该是dataType

代码语言:javascript
复制
dataType: 'json',
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23161616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档