Get error when list images by tag
I use this code to list all my image on my web page but but when I try and get the urls for the images I am getting an authentication error.
function updatePhotoAlbum(){
$.cloudinary.config({ 'cloud_name': ' ', 'api_key': ' ', "api_secret": " "});
var url = $.cloudinary.url('logo', {format: 'json', type: 'list'});
$.ajax({
type:"GET",
crossDomain: true,
url: url,
success: function(response){
for (var key in response.resources) {
var result="http://res.cloudinary.com/dtnnxpurc/image/upload/"+response.resources[key].public_id;
$("#album").append("<div>");
$("#album").append($.cloudinary.image(response.resources[key].public_id,{width: 150, height: 100, class:"images", data:result }));
var delete_token=localStorage.getItem(response.resources[key].public_id);
$("#album").append("<button id='delete' public_id="+response.resources[key].public_id+" data="+delete_token+">Delete</button></div>");
}
$(".images").click(function(){
var a = $("<a>")
.attr("href", $(this).attr('data'))
.attr("download", "image.png")
.appendTo("body");
a[0].click();
a.remove();
});
$("#delete").click(function(){
var result=$.cloudinary.delete_by_token($(this).attr('data'));
result.fail(function(e){
alert(JSON.stringify(e.responseJSON.error.message));
});
result.done(function(e){
alert("Image is deleting");
});
localStorage.removeItem($(this).attr('public_id'));
});
}
});
}
Is there some problem in my code?
Post is closed for comments.
Comments
1 comment