I am using Laravel and Mongodb.
My JSON output:
[{"_id":"58aabc59836a0656da4e4c71",
"userid":"KT0001",
"username":"Ashok kumar",
"email":"[email protected]",
"mobileno":8015681377,
"manager_mail":"[email protected]",
"roleid":2,
"role": {"_id":"58996226d31868ea68c7b52c",**"roleid":2,"rolename":"Admin"**}
},
]
I want to get the role id and role name, i can get the other details except rolename, i tried retrieving it with the following but no result.
for(i=0;i<userdata.length;i++)
{
$('<option/>', {
value: userdata[i].roleid,
html: userdata[i][role].rolename
}).appendTo('select#userrole');
};
Please help?
userdata[i][role].rolenamebyuserdata[i]['role'].rolenameand try again.