2011-04-30 98 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