javascript - Retrieve values from a JSON -


i want extract tenantid value below given json

{   "clientaccounts":{    "@tenantid":"entprisedemo",    "clientaccount":[     {      "guid":"447a0bac-51e0-4f5f-b504-97dca5825530",      "totalvalueformatted":"$1,100,000"     }    ]   } } 

this javascript function calling ajax request , success function code

$.ajax({       url: "$clientaccountsurl",       cache: false,       datatype: "json", // set json or xml       success: function(data){          alert(data.clientaccounts.tenantid);       }  }); 

when i'm alerting value of tenantid in success function it's returning me undefined value though checked on firebug available in json array.

is there way retrieve value of tenantid.

you should able access using associative array:

data.clientaccounts['@tenantid'] 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -