Popup with variable value question?

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.

The src argument should have quotes:

Maybe the browser “corrects” this when it is directly in the source, but not when added dynamically.

Thanks Tim. Yes you are right, but thats not the problem.
Is that the variable is undefined, I will update with some more code :slight_smile: