How to read json data with JavaScript or jQuery -


i'm getting response when executing upload button page (i'm using jquery file upload).

readystate: 4 responsetext: {"files":[{"name":"my_picture.jpg","size":79362,"type":"image\/jpeg","url":"https:\/\/www.mysite.com\/lib\/plugins\/jquery-file-upload-9.11.2\/server\/php\/files\/55_ads_1_preuzmi.jpg","mediumurl":"https:\/\/www.mysite.com\/lib\/plugins\/jquery-file-upload-9.11.2\/server\/php\/files\/medium\/55_ads_1_preuzmi.jpg","thumbnailurl":"https:\/\/www.mysite.com\/lib\/plugins\/jquery-file-upload-9.11.2\/server\/php\/files\/thumbnail\/55_ads_1_preuzmi.jpg","deleteurl":"https:\/\/www.mysite.com\/lib\/plugins\/jquery-file-upload-9.11.2\/server\/php\/index.php?file=55_ads_1_preuzmi.jpg","deletetype":"delete"}]} responsejson: [object object] status: 200 statustext: ok 

i want grab name key value, nothing else not need. i'm stuck reading name field value title "name" (i want grab this: my_picture.jpg). how can grab javascript/jquery?

you can use jquery.parsejson()

var obj = jquery.parsejson( '{ "name": "john" }' ); alert( obj.name === "john" ); 

with example can values :

for (var in obj.files){     console.log(obj.files[i]); // here whole object     console.log(obj.files[i].name); // here name of object } 

if have 1 entry, use code blazemonger put in comments of answer :)


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -