Im creating a popup as below and if I have the image directly in the code then it works as it should, but if I have the image code in a variable and have the variable in the code, then it does´t work.
It says it undefined if I have it in the variable?
function infoPopUp(){
var data;
var datatest;
app.request({
method: 'POST',
url: 'shop/loggain/popupinfo.asp',
data: {
userId : 1,
kategori: 1
},
success: function (data) {
if(data){
datatest='<img src="image.jpeg" class="popup-close" />'
datatest=String(datatest)
console.log(datatest)
}
}
});
var infoPopup = app.popup.create({
content: '<div class="popup ">'+
'<div class="page popup-page">'+
'<div class="page-content popup-page-content" >'+
'<div class="block" >'+
'<img src="image.jpeg" class="popup-close" />'+ //if I use this it works
datatest + //if I use this it opens the popup but, then I get undefined
'</div>'+
'</div>'+
'</div>'+
'</div>',
});
}
So what am I missing? Thanks.