1
Answer

Array in jquery

Can someone please tell me what wrong with this jquery because i am not getting any error can not get value in var lbl and var dat var lbl = []; var dat = []; $.ajax({ url: "../Graph/GetData", type: "Post", data: "{}", dataType: "json", success: function (data) { $.each(data, function (key, value) { lbl.push[value.Item]; dat.push[value.price]; alert("Item" + lbl + " Price" + dat) }) } });
Answers (1)
0
Amit Kumar

Amit Kumar

NA 3.5k 203.6k 7y
Hi Shiv,
             use the below code. 
  1. var lbl = [];   
  2. var dat = [];  
  3. $.ajax({  
  4. url: "../Graph/GetData",  
  5. type: "Post",  
  6. data: "{}",  
  7. dataType: "json",  
  8. success: function (data) {  
  9. $.each(data, function (key, value)  
  10. {  
  11. lbl.push(value.Item);  
  12. dat.push(value.price);  
  13. alert("Item" + lbl + " Price" + dat);  
  14. })   
  15. }  
  16. });  
 
Accepted