2011-04-30 96 views
1

HI,無法提取值,我剛剛的forEach,ItemFileReadStore,JSON.parse

我取出由數據庫中的值,並把值的JSONObject 像

[{"JAN":"17"},{"FEB":"19"},{"MAR":"21"},{"APR":"23"},{"MAY":"24"},{"JUN":"27"}] 

是把JSONObject的後在JSONArray中並將響應發送回jsp頁面。

在JSP:

dojo.xhrGet({ 
     url : "/POC/Action.do", 
      handleAs : "json", 
      sync: true, 
      load : function(response, ioArgs) { 
       alert("retrived response ------"+response); 
        //Here i need to fetch only the values like {17,19,21,23,24,27} not the key from response.. but i am unable to fetch it 

       return response; 
      }, 
       error: function(response, ioArgs){ 
       dojo.byId("grid").innerHTML = "An error occurred, with response: " + response;    return response; 
      }, 
      handleAs: "json" 
     }); 

需要獲取只有像{17,19,21,23,24,27}的值不響應的關鍵..但我無法獲取它。我的forEach,ItemFileReadStore,JSON.parse卻無力..請幫助

回答

0

如果從Web服務器響應的(你可以檢查使用招等)的數據如下:

[{"JAN":"17"},{"FEB":"19"},{"MAR":"21"},{"APR":"23"},{"MAY":"24"},{"JUN":"27"}] 

然後,你可以在下面做響應處理程序:

var output = []; 
for(var i in response) 
    for(var x in response[i]) 
    output.push(response[i][x]); 

輸出數組將有你需要

+0

感謝老闆對快速反應的所有值..它的工作.... – 2011-04-30 10:41:03