I get the images from a database and will add this to a array for the backstrech-Plugin.
This is the code I created:
/*
Get topslider
*/
function getHomeSlider()
{
var data = {};
var url = $( "#preloader" ).data( "url-slider" );
var imgArray = new Array();
$.ajax({
type: "POST",
url: url,
data: data,
dataType: "json"
})
.done(function(resp){
$.each(resp, function(i, item) {
imgArray.push( "http://192.168.1.30/attractionimages/" + item.folder + "/" + item.filename );
});
console.log(imgArray);
return imgArray;
})
.error(function(resp){
});
}
$(".home-fullscreen-slider").backstretch(getHomeSlider(), {
fade: 750,
duration: 4000
});
When i make console.log of the imgArray, I got the following value:
["http://192.168.1.30/attractionimages/a23bz/DSC_0073.JPG", "http://192.168.1.30/attractionimages/a23bz/DSC_0135.JPG", "http://192.168.1.30/attractionimages/a23bz/DSC_0179.JPG", "http://192.168.1.30/attractionimages/a23bz/DSC_0273.JPG"]
Every Image is available, because, when i add this String instead of the function-call, then the images will be viewed. So the images are callable and available.