Javascript 使用jquery解析Json-未获取值
我从服务器获取以下值Javascript 使用jquery解析Json-未获取值,javascript,jquery,json,Javascript,Jquery,Json,我从服务器获取以下值 {"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"}]} 我需要获得发送值、类别、经验时间、发送id、分数、功能、op等
{"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"}]}
我需要获得发送值、类别、经验时间、发送id、分数、功能、op等
到目前为止,我已经试过了。但是没有得到任何价值
var result = jQuery.parseJSON(data);
$.each(result, function(index, value) {
alert(value.score);
});
试试这个
var jsonString='{“状态”:{“消息”:“成功”,“代码”:200},“数据”:[{“发送”:“测试”,“类别”:“Appo”,“经验时间”:“2014-10-07”,“发送id”:4501922,“类别id”:4011,“分数”:“负面”,“特征”:“emp”,“op”:“挑战”});
var result=jQuery.parseJSON(jsonString);
$.each(结果、数据、函数(索引、值){
警报(值、分数);
});代码>
您需要使用$.each(result.data,function(index,value){})
因为result.data
包含要迭代的数组,所以在调用jQuery.parseJSON(data)
之前,请确保data
是字符串而不是对象-检查浏览器控制台是否有任何错误?尝试此操作,发出警报(data['score']);