Question: I need to load database content according to the following scheme into the variable `data`.

```
var data = {
    "62": {
        sku: "62",
        section: "bodyImage",
        img: "images/diy-images/config-images/62.png",
        label: "plain red",
        price: "100"
    },
    "63": {
        sku: "63",
        section: "bodyImage",
        img: "images/diy-images/config-images/63.png",
        label: "plain pink",
        price: "110"
    },
    "360": {
        sku: "360",
        section: "bodyImage",
        img: "images/diy-images/config-images/360.png",
        label: "plain gray",
        price: "120"
    },
};​

```

I tried to achieve that with the following function but it doesn't work out. What am I missing?

```
var data = (function() {
    $.ajax({
        url: 'get_data.php',
        data: "",
        dataType: 'json',
        success: function(rows) {
            for (var i in rows) {
                var row = rows[i];

                var id = row[0];
                var section = row[1];
                var img = row[2];
                var label = row[3];
                var price = row[4];
            }
        }
    });
});​

```

Answer: 
```
var data = {}; // data variable for future use
$.ajax({
 url: '',
 data: '',
 dataType: 'json',
 success: function(rows) {
   $.each(rows, function(i, val) {
      var id = val.sku,
          section = val.section,
          img = val.img,
          label = val.label,
          price = val.price;
   });
   // if you want to update data variable then
   data[sku] = {sku: sku, img: img, section: section, label: label, price: price};
  // to set data to a content
   $('#output_div').html(JSON.stringify(data));
 }
})

```
You can address the properties by name:

```
for (var i in rows) {
    var row = rows[i];          

    var id = row.sku;          // or var id = i;
    var section = row.section;
    var img = row.img;
    var label = row.label;
    var price = row.price;
    ...
}

```