I'm getting this response when executing upload button from my 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 just want to grab name key value, nothing else I do not need. I'm stuck with reading name field value with title "name" (I want to grab this: MY_PICTURE.JPG). How can I grab it with JavaScript/jQuery?
xhr.responseText.files[0].name?xhrbeing the supposed object containing the JavaScript data you posted. If my previous expression doesn't work, you may have to parse the JSON data withJSON.parse:JSON.parse(xhr.responseText).files[0].nameJSON.parse(json_string) // renders objectandJSON.stringify(json_object) // renders string