My java script. I want to display an image. javascript requires an image path as an array. I tried to put the ajax path. this does not work. when I use the hard code of his work. my javascipt is below. this does not work. working code code below javascript and my php file code is also there.
$(function () {
$.get( "php/building_edit_image_get_db.php", function( your_return_data ) {
alert(your_return_data);
$("#editimagefile").fileinput({
showUpload: false,
showCaption: false,
overwriteInitial: true,
initialPreview: [your_return_data],
initialPreviewAsData: true,
initialPreviewFileType: 'image',
browseClass: "btn btn-primary btn-lg",
allowedFileExtensions : ['jpg', 'png','gif']
});
});
});
This does not work. when I install hard code that it works correctly, the script is below
$(function () {
$.get( "php/building_edit_image_get_db.php", function( your_return_data ) {
alert(your_return_data);
$("#editimagefile").fileinput({
showUpload: false,
showCaption: false,
overwriteInitial: true,
initialPreview: [
"http://lorempixel.com/800/460/people/1",
"http://lorempixel.com/800/460/people/2"
],
initialPreviewAsData: true,
initialPreviewFileType: 'image',
browseClass: "btn btn-primary btn-lg",
allowedFileExtensions : ['jpg', 'png','gif']
});
});
});
My php file to save the value of the array.
session_start();
require_once ('../aiboc_admin/class/Buidling_Image.php');
$editid = $_SESSION['BUILD_LIST_EDIT_ID'];
$getimgs = Buidling_Image::GetGalleryImageByID($editid);
foreach ($getimgs as $setimgs)
{
$imgs[] = $setimgs['img_url'];
}
echo json_encode($imgs,JSON_UNESCAPED_SLASHES);