Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 22nd, 2012  |  syntax: None  |  size: 0.63 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ok, I really don't get on with JSON stuff?
  2. $.getJSON("jsonOut/products.aspx?barcode=yes", function () { alert(data.label);  });
  3.        
  4. $.getJSON("/jsonOut/products.aspx?barcode=yes", function (data) { alert(data[0].label);  });
  5.        
  6. $.getJSON("/jsonOut/products.aspx?barcode=yes", function (data) {
  7.    for (var i = 0; i < data.length; ++i) {
  8.       alert(data[i].label);
  9.    }
  10. });
  11.        
  12. $.getJSON(
  13.      "jsonOut/products.aspx?barcode=yes",
  14.      function (data) {
  15.          alert(data.label);  
  16. });
  17.        
  18. [
  19.    {
  20.         "label": "Boss TR-2 Tremolo Pedal",
  21.         "price": 79,
  22.         "id": 1287
  23.     }
  24. ]
  25.        
  26. data[0].label
  27.        
  28. console.log(data);