简体   繁体   English

从 Json object 检索数据

[英]retrieve the data from Json object

I am learning json now.我现在正在学习 json。

$.ajax({  
        async: true,  
        type: "POST",  
        url: "get.....values.asp",  
        data: "vendorId="+vendor,  
        success: function(json){    
            alert( "Data retrieved: " + json );   
        }  
    });  

I am using this ajax call to get the data as json and data is coming as fallowing:我正在使用此 ajax 调用来获取 json 的数据,并且数据即将发布:

{"rows": [  
         {"cell":[  
                  104,100,140,"2.99",0.1,1,14,123.55  
                 ]   
          }   
]}   

How can i retrieve the data from this json object?如何从此 json object 中检索数据?
can any one give Idea?任何人都可以给Idea吗? thanks in advance.提前致谢。

$.parseJSON(json) will do the work. $.parseJSON(json)将完成这项工作。

Have you tried...你有没有尝试过...

json.rows[0].cell[0]

...etc.? ...ETC。?

I also notice you haven't specific the datatype when calling your $.ajax function, eg我还注意到您在调用 $.ajax function 时没有具体说明数据类型,例如

$.ajax({
async: true,
type: "POST",
url: "get.....values.asp",
data: "vendorId="+vendor,
dataType: 'json',
success: mySuccessHandler
});

Try running it through a for loop in the callback function and assign variables to the bits of information you want to use.尝试通过回调 function 中的 for 循环运行它,并将变量分配给您要使用的信息位。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM