javascript - jQuery Ajax object dot notation undefined from REST -


hey guys having big problem understanding why each unable parse restful end point within ajax success function:

so have following code:

$.ajax({   datatype: "json",   url: '/showroom-event-gallery-api',   success: function(data) {     var rawdata = data.slice(0,10);     console.log(rawdata);     (var = 0, len = rawdata.length; < len; i++) {       var imagename = rawdata.name;       console.log(imagename);     }   } }); 

the console.log(rawdata); statement runs , shows objects rest api. issue having when try , use dot notation select parameter called name within of objects , store them variable.

when console.log(imagename); undefined name parameter inside object unsure why happening?

here example of data:

[       {          id:225,        car_image_category_id:37,        image_name:"dsc_9672",        name:"77a3b8f84d63557d165f3b4ecf0d079e5cd1ae67.jpg",        path:"img/imagedb/77a3b8f84d63557d165f3b4ecf0d079e5cd1ae67.jpg",        thumbnail_path:"img/imagedb/thumbs/tn-77a3b8f84d63557d165f3b4ecf0d079e5cd1ae67.jpg",        created_at:"2016-07-27 18:13:50",        updated_at:"2016-07-27 18:13:50"     },     {          id:226,        car_image_category_id:37,        image_name:"dsc_9673",        name:"af508985a53d7288d58cea118389a58b3567b364.jpg",        path:"img/imagedb/af508985a53d7288d58cea118389a58b3567b364.jpg",        thumbnail_path:"img/imagedb/thumbs/tn-af508985a53d7288d58cea118389a58b3567b364.jpg",        created_at:"2016-07-27 18:13:50",        updated_at:"2016-07-27 18:13:50"     },     {          id:227,        car_image_category_id:37,        image_name:"dsc_9677",        name:"85832b6a6d952873f2e277ca19b5eab826d63340.jpg",        path:"img/imagedb/85832b6a6d952873f2e277ca19b5eab826d63340.jpg",        thumbnail_path:"img/imagedb/thumbs/tn-85832b6a6d952873f2e277ca19b5eab826d63340.jpg",        created_at:"2016-07-27 18:13:51",        updated_at:"2016-07-27 18:13:51"     }  ] 

as can see name available selected when use dot notation variable comes undefined.

any idea why might happening?

thanks

it should rawdata[i].name

   (var = 0, len = rawdata.length; < len; i++) {       var imagename = rawdata[i].name;       console.log(imagename);     } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -