从Json中提取特定值

时间:2016-07-04 06:28:19

标签: jquery

我的结果为[{"BlockRefHandle":"11B67"}]

我们如何提取数据11B67

$.ajax({
    type: 'POST',
    url: url,
    data: getDatawithToken(params),
    dataType : 'json', // expecting json returned from server
    success: function (result) {
        alert("success");  
        if (result.d.length > 0) {
            // access first element 
            alert(result.d[0]);   
        }  
    }
});

1 个答案:

答案 0 :(得分:1)

您可以通过访问属性BlockRefHandle来提取所需的值,如下所示:

$.ajax({
    type: 'POST',
    url: url,
    data: getDatawithToken(params),
    dataType : 'json', // expecting json returned from server
    success: function (result) {
        alert("success");  
        if (result.length > 0) {
            // access first element 
            alert(result[0].BlockRefHandle);   
        }  
    }
});