In this tutorial i’m going to print the object value using javascript ?
First go to controller function and put below code.
public function getslugbasedDashbaord($findingSlugName, $authId)
{
Log::info('oncontinue dashboard open' .$findingSlugName);
log::info('authId me kya aa rha hai' .$authId);
Log::info('ab in kr gye hai isme new wala me');
$slug_dashboard = Userorganisation::where('u_org_slugname', $findingSlugName)->where('u_org_user_id', $authId)->first();
Log::info('slug_dashboard in kr gye hai isme new wala me'.$slug_dashboard);
$slug_based_rollId = $slug_dashboard['u_org_role_id'];
$slug_based_status = $slug_dashboard['status'];
$slug_based_u_org_organization_id = $slug_dashboard['u_org_organization_id'];
$response = [
'success' => true,
'data' => $slug_dashboard,
'slug_based_rollId' => $slug_based_rollId,
'slug_based_status' => $slug_based_status,
'slug_based_u_org_organization_id' => $slug_based_u_org_organization_id,
'message' => 'Data retrieved successfully.',
];
return response()->json($response, 200);
}
Next go to blade page and put below code
$.ajax({
type: 'get',
url: "{{ url('api/v1/j/invitedManagerUserGetting') }}/" + userAuthId + '/' +
organisation_id,
dataType: "json",
async: false,
dataSrc: 'data',
"beforeSend": function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + localStorage.getItem(
'a_u_a_b_t'));
},
success: function(data) {
console.log(data.data);
console.log('success main mamager id value a rha hai ki nahi', data);
data.forEach(obj => {
console.log(JSON.stringify(obj));
});
var p_name = ('#project_manager');
// $(p_name).empty();
$.each(data, function(i, link) {
$('#project_manager').append('<option name="' + link.u_org_user_email +
'" value="' + link.u_org_user_email + '">' + link
.u_org_user_email + '</option>');
});
}
});