function changeImage() { var masterGameId = $('#newFavoriteGame').val(); var obj = new getObj('newFavoriteGameDiv'); var img = document.images['newFavoriteGameImg']; if (masterGameId == 0) { obj.style.background = "url('https://cdn.ghstatic.com/images/site/zylom/blank.gif') no-repeat"; img.src = "https://cdn.ghstatic.com/images/site/zylom/funpass/en/nogame.jpg"; } else { var url = "/myaccount/includes/favorites/mastergame.jsp?g=-1&gid=" + masterGameId + "&nocache=" + new Date(); ajaxConnection = new AJAXConnection(url); ajaxConnection.get(); urlBackground = "https://cdn.ghstatic.com" + ajaxConnection.getResponseText(); urlBackground = urlBackground.replace(/\n/g, ""); console.log(urlBackground); obj.style.background = "url('" + urlBackground + "') no-repeat"; img.src = "https://cdn.ghstatic.com/images/site/zylom/overlay.gif"; } }