3
$("#loginsubmit").live("click", function() {
    var request = new Request();
    request.service = "http://88.80.223.163:8080/lumiin-service/lumiin/control/eventmap/1" ;
    RequestHandler(request,displayData);
});  

function displayData(data) {
    //alert(data.contents.ownerId);
    var cont =  data.contents;
    $("#mono").html(''+cont.id);
}

我正在使用上面的代码片段来获取 id,它工作正常......我如何获得firstName

目的:

{
  "id": 1,
  "eventId": {
    "URL": "web",
    "location": "web",
    "url": "web",
    "id": 54,
    "type": {
      "name": "Meeting",
      "id": 1,
      "isDeleted": "N",
      "description": "Meeting"
    },
    "abteilung": {
      "id": 165,
      "code": "web123",
      "isDeleted": null,
      "domainId": 0,
      "parentId": 164,
      "description": null
    },
    "eventName": "Tanvi",
    "place": "web",
    "startDate": 1335830400000,
    "endDate": 1337558400000,
    "prospectId": null,
    "person": "web",
    "isDeleted": "N",
    "countryId": {
      "name": "CH",
      "id": 1,
      "isDeleted": "N",
      "description": "Switzerland"
    },
    "followUp": null,
    "budget": 0,
    "description": "web"
  },
  "ownerId": {
    "id": 67,
    "firstName": "web123",
    "localOrg": null,
    "industryTypeId": null,
    "memeber": false,
    "profileType": "Manager",
    "emailId": "web123",
    "abteilung": {
      "id": 165,
      "code": "web123",
      "isDeleted": null,
      "domainId": 0,
      "parentId": 164,
      "description": null
    },
    "userCode": "web123",
    "authenticatedAccess": -1,
    "uuid": null,
    "lastName": "web123",
    "isDeleted": "N",
    "passWord": "web123",
    "fullName": "web123,web123",
    "status": 0
  },
  "prospectId": {
    "id": 303,
    "firstName": "web123",
    "emailId": "web123@gg.com",
    "ownerId": {
      "id": 67,
      "firstName": "web123",
      "localOrg": null,
      "industryTypeId": null,
      "memeber": false,
      "profileType": "Manager",
      "emailId": "web123",
      "abteilung": {
        "id": 165,
        "code": "web123",
        "isDeleted": null,
        "domainId": 0,
        "parentId": 164,
        "description": null
      },
      "userCode": "web123",
      "authenticatedAccess": -1,
      "uuid": null,
      "lastName": "web123",
      "isDeleted": "N",
      "passWord": "web123",
      "fullName": "web123,web123",
      "status": 0
    },
    "abteilung": {
      "id": 165,
      "code": "web123",
      "isDeleted": null,
      "domainId": 0,
      "parentId": 164,
      "description": null
    },
    "startDate": 1335744000000,
    "endDate": 1337904000000,
    "statusId": {
      "name": "New",
      "id": 1,
      "isDeleted": "N",
      "description": "New"
    },
    "company": "company",
    "lastName": "web123",
    "isDeleted": "N",
    "yearofBirth": null,
    "annualRevenue": 0,
    "nationalityId": {
      "name": "CH",
      "id": 1,
      "isDeleted": "N",
      "description": "Switzerland"
    },
    "titleId": {
      "name": "Mr",
      "id": 1,
      "isDeleted": "N",
      "description": "Mr"
    },
    "maritalstatusId": null,
    "residencyId": null,
    "languageId": null,
    "priorityId": {
      "name": "Low",
      "id": 1,
      "isDeleted": "N",
      "description": "Low"
    },
    "genderId": {
      "name": "Male",
      "id": 1,
      "isDeleted": "N",
      "description": "Male"
    }
  },
  "isDeleted": "N"
}
4

1 回答 1

2

firstName是对象的属性,您prospectId可以通过以下方式读取它:

var firstName = data.prospectId.firstName;
var lastName = data.prospectId.lastName;

小提琴

于 2012-08-12T12:01:21.450 回答