Put the following line before your var iconCode = result.weather[0].icon;. Then check your browser’s console to view the result of the console.log statement. I think you will be surprised at what you do not see for some lat/longs.
You need you url to attach to href attribute of your $("#myIcon") element i suppose? If so:
$("#myIcon").attr(“href”,iconUrl);
or if you use vanilla js:
document.getElementById(“myIcon”).href = iconUrl;
About a icon thingy:
$("#myIcon").prepend("");
This being said, you can use html(), but that will replace everything in $("#myIcon") element. Prepend just adds it before rest of elements in $("#myIcon") element. .