0

I have this JSON data:

[{"sequence":"503","accountnumber":"0001","telephonenumber":null,"emailaddress":"email@domain.com","directdebit":"Y","auto_directdebit":"","billing_address":{"title":"Mr","forename":"Joe","surname":" Bloggs","address1":"ADDR1","address2":"","address3":"","town":"TOWN","county":"COUNTY","postcode":"PC","country":"United Kingdom","default_invoice":"1","default_delivery":"1"}}]

And I use the following to retrieve the details:

$.ajax({
    type: "GET",
    url: "/section/get_data?getCustomer=1&sequence=" + $("#customersequence").val(),
    data: $(this).serialize(),
    success: function(data) {
        alert(data[0].accountnumber);
    }
});

which works but i cannot figure out how to return billing_address

i have tried:

data[0].billing_address[0].address1

but that did not work

how can i retrieve each field under billing_address

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
charlie
  • 415
  • 4
  • 35
  • 83

1 Answers1

1

you are almost there, the only thing is that billing_address is not an array... remove the try to get the element with [0] like

data[0].billing_address.address1
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97