Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Getting list of images from database

Hi,
While fetching a list of informations which includes pictures from a database table, I fetch the list of the names of that pictures and trying to show each of the pictures that I got its names with the code below :

var data2;
var serverUrl = 'https://api.appery.io/rest/1/db/files/' + value;
$.ajax({
type: "GET",
headers: {'X-Appery-Database-ID':deneme_settings['database_id'],'X-Appery-Session-Token':localStorage.getItem('sessionTokenId')},
url: serverUrl,
processData: false,
success: function(data) {
console.log("Successfully loaded");
data2= "data:image/png;base64," + data;
flag = false;
},
error: function(xhr) {
console.log("Load error: " + xhr.status + " " + xhr.responseText);
}
});
return data2;

The code returns before the picture is uploaded, so the place that the picture should be there stays blank. How can I make wait the code to provide it is uploaded before returning?

Best regards,
Edebali

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Getting list of images from database

Hello! If we understand correctly you have this code in response Mapping? $.ajax function work is not sync. So you need to change your code https://gist.github.com/anonymous/29a...

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Getting list of images from database

Thank you for quick reply. Yes i using this code in response mapping. it is getting image name as value. My mapping looks like below:
Image

when i used the code that you suggested i get the "Failed to load resource " error at
"$(element).attr('src', data2);"
line.

What do you think about the reason of the error?

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Getting list of images from database

by the way i am loading files directly via appery database interface. They are not base64 images.

Mehmet Edebali Şener
Posts: 0
Joined: Thu May 30, 2013 7:33 pm

Getting list of images from database

I made it with "Direct link to a file".

http://docs.appery.io/documentation/b...

Thanks for advice again.

Anton Artyukh5836028
Posts: 0
Joined: Wed May 08, 2013 12:57 pm

Getting list of images from database

Glad to hear that. Thanks for a notice.

Return to “Issues”