简体   繁体   中英

retrieve the data from Json object

I am learning json now.

$.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:

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

How can i retrieve the data from this json object?
can any one give Idea? thanks in advance.

$.parseJSON(json) will do the work.

Have you tried...

json.rows[0].cell[0]

...etc.?

I also notice you haven't specific the datatype when calling your $.ajax function, eg

$.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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