I am trying to append an image path to the img src attribute but src shows (unknown). The image path is retrieved successfully from Database (I console.logged). I don't know why is not return the path string. Thanks in advance
function loadData() {
dbHandler.dataBase.transaction(function (tx) {
tx.executeSql('SELECT * FROM Properties', [], function (tx, results) {
var len = results.rows.length, i;
var list="";
for (i = 0; i < len; i++){
$('#propertiesList').append(`<li>
<a onClick="fullDetails(${ results.rows.item(i).propertyRef})">
<img src="${propertyImg(results.rows.item(i).propertyRef)}">
<h2><strong>£ ${ results.rows.item(i).monthFee} Pcm </strong></h2>
<p>${ flatType (results.rows.item(i).bedQty)} ${ results.rows.item(i).propertyType} to rent in ${ results.rows.item(i).postcode}</p>
<p>${ results.rows.item(i).furnitureType}</p>
<p>${ results.rows.item(i).notes}</p>
<p>Listed on <strong> ${ results.rows.item(i).createdOn} by ${ results.rows.item(i).postedBy} </strong> </p>
<p class="ui-li-aside"><strong><a href=""> Available ${ results.rows.item(i).avalabilityDate}</strong></a></p>
</a>
</li>`).listview('refresh');
}
}, null);
});
function propertyImg(ref){
var myg="";
dbHandler.dataBase.transaction(function (tx) {
tx.executeSql('SELECT * FROM Propertyimages Where postRef =' + ref , [], function (tx, results) {
var ded = results.rows.length, i;
console.log(results)
var imgss="";
for (i = 0; i < ded; i++){
imgss += `${results.rows.item(i).imgPath}`;
}
myg = imgss
console.log(myg);
}, null);
})
return myg;
}
}