Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is because Object's default toString implementation results in "[object Object]" when concatenating to a String object. You can access the fields of the val object as usual, for example:</p> <pre><code>val.data.AddressID </code></pre> <p>like this:</p> <pre><code>$.each(data, function(key, val) { string += "Key: " + key + " Value:" + val.data.AddressID + "&lt;br /&gt;"; }); </code></pre> <p>Please note that val in the loop above is the {"data": ...} part of the JSON code, that is why you need to specify <em>val.data.</em> to access parts of the address data inside.</p> <p>Also, you could simply remove the <em>data</em> nesting level, resulting in a JSON layout like that:</p> <pre><code>[ {"AddressID":"10011","AddressType":"Delivery","AddressLine1":"4 Caerleon Drive","AddressLine2":"Bittern","AddressLine3":"","CityTown":"Southampton","County":"Hampshire","PostCode":"SO19 5LF","Country":"United Kingdom","ContactID":"10011"}, {"AddressID":"10012","AddressType":"Home","AddressLine1":"526 Butts Road","AddressLine2":"Sholing","AddressLine3":"","CityTown":"Southampton","County":"Hampshire","PostCode":"SO19 1DJ","Country":"England","ContactID":"10011"} ] </code></pre> <p>Using this PHP code:</p> <pre><code>while($r = mysql_fetch_assoc($addressData)){ $rows[] = $r; } </code></pre> <p>And then, you could access the address data fields in the loop like this:</p> <pre><code>$.each(data, function(key, address) { string += "Key: " + key + " Value:" + address.AddressID + "&lt;br /&gt;"; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload