2014-10-29 83 views
0

我得到以下從服務器值解析JSON使用jQuery - 沒有得到價值

{"status":{"message":"success","code":200},"data":[{"sent":"test","category":"Appo","experience_time":"2014-10-07","sent_id":4501922,"categoryId":4011,"score":"Negative","feature":"emp","op":"challenges"}]} 

我需要得到的發送,類別,experience_time,sent_id,得分,功能,運算等價值

我迄今爲止嘗試過,但沒有得到任何價值。

var result = jQuery.parseJSON(data); 

      $.each(result, function(index, value) { 

alert(value.score); 

     }); 
+3

您需要使用'$。每個(result.data,函數(指數值){});''以來的結果。 data'包含你想要迭代的數組 – 2014-10-29 06:38:58

+0

在調用'jQuery.parseJSON(data)'前確保'data'是一個字符串而不是對象' - 檢查你的瀏覽器控制檯是否有任何錯誤? – 2014-10-29 06:40:07

+0

Thanks.I將嘗試 – aniltc 2014-10-29 06:41:12

回答

1

試試這個,

var jsonString = '{"status":{"message":"success","code":200},"data":[{"sent":"test","category":"Appo","experience_time":"2014-10-07","sent_id":4501922,"categoryId":4011,"score":"Negative","feature":"emp","op":"challenges"}]}'; 
 

 

 
var result = jQuery.parseJSON(jsonString); 
 

 
$.each(result.data, function(index, value) { 
 

 
    alert(value.score); 
 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>