I have problem passing the id to the api url of ajax, there is no response to my success function when I click the a href tag.
So first I need to fetch all the Albums, And It's already done and fetched well. so the codes is this.
Function Getting All the Albums:
$(document).ready(function(){
$.ajax({
url:'http://localhost:8000/api/peoplegallery',
dataType: "json",
contentType: "application/json",
success:function(response) {
var peoplegallery = response[0].gallery_table;
$.each(peoplegallery, function (index, el) {
var stringify_list_gallery = jQuery.parseJSON(JSON.stringify(el));
var gallery_file = stringify_list_gallery['file'];
var people_gallery_image = '<img src=/storage/' + gallery_file + ' class="d-block w-100">';
var gallery_id = stringify_list_gallery['content_id'];
var gallery_content_title = stringify_list_gallery['content_title'];
var gallery_event_dated = stringify_list_gallery['event_dated'];
var peoplegallery_data;
peoplegallery_data =
'<div class="col-md-4">\
<div class="card" style="margin-left:20px;">\
<img class="card-img-top" src="/storage/'+gallery_file+'" alt="Card image cap" style="height:200px;">\
<div class="card-body">\
<h5 class="card-tilte">\
<a href="/peoplegallery_album/'+gallery_id+'" class="clicked_albums" data-id='+gallery_id+' style="color:black; font-weight: 500;">'+gallery_content_title+'</a>\
</h5>\
</div>\
<div class="card-footer">\
<small class="text-muted"><i class="icon ion-md-calendar" style="font-size:15px; color:#800000;"></i><i class="far fa-calendar-check"></i> '+gallery_event_dated+'</small>\
</div>\
</div>\
<br><br>\
</div>\
';
$('#list_peoplegallery').append(peoplegallery_data);
});
},
error:function(response) {
console.log(response);
}
});
});
So the output look likes this, I will give example
If I click that I want to get all the images inside of that album, so I created a function to get all the images but the problem is I can't get the ID.
Function to get the specific images to the album.
$(document).ready(function(){
$(document).on('click','.clicked_albums',function() {
var album_id= $(this).data('id');
$.ajax({
url:'http://localhost:8000/api/peoplegallery_album/'+ album_id,
dataType: "json",
contentType: "application/json",
success:function(response) {
console.log(response);
},
error:function(response) {
console.log(response);
}
});
});
});
So i give remedy to validate if the value is returning i use preventDefault it works, but when my browser go to the second page. the Id is refreshing.. that's why i can't get the response, so how it will solved.?
e.preventDefault();