Javascript:访问对象(Javascript: Access an object)

我正在使用console.log(data.result)来发现对象层次结构,这是输出:

[ 目的 delete_type:“删除” delete_url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/?file=splash%20%2816%29.png” 名称:“splash(16).png” 大小:17369 thumbnail_url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/thumbnails/splash%20%2816%29.png” 输入:“image / png” url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/files/splash%20%2816%29.png” proto :对象

像我这样的菜鸟如何访问这个对象......? 谢谢! 我想要这个名字:)

更新 执行console.log(data.result) 警报(data.result.name);

警报回来了!

I'm using console.log(data.result) to discover an object hierarchy, here's the output:

[ Object delete_type: "DELETE" delete_url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/?file=splash%20%2816%29.png" name: "splash (16).png" size: 17369 thumbnail_url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/thumbnails/splash%20%2816%29.png" type: "image/png" url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/files/splash%20%2816%29.png" proto: Object

How does a noob like myself access this object ...? Thanks! I want the name :)

Update console.log(data.result) alert(data.result.name);

The alert comes back null!

最满意答案

自开场以来很难说[没有关闭,但我认为这意味着对象包含在一个数组中,所以你可以访问它:

data.result[0].name

It's hard to tell since the opening [ isn't closed, but I assume it means the Object is contained in an array, so you'd access it like:

data.result[0].nameJavascript:访问对象(Javascript: Access an object)

我正在使用console.log(data.result)来发现对象层次结构,这是输出:

[ 目的 delete_type:“删除” delete_url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/?file=splash%20%2816%29.png” 名称:“splash(16).png” 大小:17369 thumbnail_url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/thumbnails/splash%20%2816%29.png” 输入:“image / png” url:“http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/files/splash%20%2816%29.png” proto :对象

像我这样的菜鸟如何访问这个对象......? 谢谢! 我想要这个名字:)

更新 执行console.log(data.result) 警报(data.result.name);

警报回来了!

I'm using console.log(data.result) to discover an object hierarchy, here's the output:

[ Object delete_type: "DELETE" delete_url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/?file=splash%20%2816%29.png" name: "splash (16).png" size: 17369 thumbnail_url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/thumbnails/splash%20%2816%29.png" type: "image/png" url: "http://doubleyourlikes.com/lab/time/jq-file-upload/server/php/files/splash%20%2816%29.png" proto: Object

How does a noob like myself access this object ...? Thanks! I want the name :)

Update console.log(data.result) alert(data.result.name);

The alert comes back null!

最满意答案

自开场以来很难说[没有关闭,但我认为这意味着对象包含在一个数组中,所以你可以访问它:

data.result[0].name

It's hard to tell since the opening [ isn't closed, but I assume it means the Object is contained in an array, so you'd access it like:

data.result[0].name