簡體   English   中英

我無法將嵌套元素的json字符串解析為jquery

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM