1 of 2 embedded code elements running on published site

When I am in the site editor, the 2 html scripts run just fine and do what they are supposed to do but when I publish the site and head to the page, only 1 element shows up and there is nothing displayed for the other element. Included screenshots in editor and the published page. Also, here is the code running (which runs fine in any html editor): 

<!DOCTYPE html>
<html>

<body onload="loadDoc()">
    <div id="info">

    </div>

    <script>
        function loadDoc() {
            var xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (this.readyState == 4 && this.status == 200) {
                    var info = JSON.parse(this.responseText);

                    var launches = info.launches[0];

                    var mission = launches.missions[0];

                    var detail = mission.description;

                    document.getElementById("info").innerHTML = detail;
                    
                }
            };
            xhttp.open("GET", "https://launchlibrary.net/1.4.1/launch?agency=121&next=1&mode=verbose", true);
            xhttp.send();
        }
    </script>
</body>

</html>

Editor ViewPublished Page

1,469 Views
Message 1 of 13
Report
12 REPLIES 12
Square

What's the name of the site?
1,458 Views
Message 14 of 13
Report

Beginners Guide to (almost) Everything SpaceX - https://spacex-guide.weebly.com/

Specific page: https://spacex-guide.weebly.com/mission-control-wip.html

1,453 Views
Message 14 of 13
Report

Also, I have an image stored in the theme and it doesn't load on the published page

1,450 Views
Message 14 of 13
Report
Square

You have SSL enabled on your site, but the scrip is referencing http. I think if you change the urls in the script to https they should show. Or you will need to generate new code somewhere. What page is the missing image on? 

1,428 Views
Message 14 of 13
Report

None of my scripts request an http source; they all request https sources. The image is under the Assets folder and it loads in the editor, but not on the published page.

1,426 Views
Message 14 of 13
Report
Square

The code for your image seems to be using http. I'm not sure if that's the root cause of why it isn't display, but it's possible. For your other code are you including the HTML and BODY tags in your embed code element?

1,422 Views
Message 14 of 13
Report

Thanks for catching that. I changed it to https but it still won't load on the publsihed page (Image is at the link I point to: https://spacex-guide.weebly.com/files/theme/Patch_Coming_Soon.jpg). All the scripts do have HTML and Body tags. I tried the scripts on another provider and they all loaded fine. Could there be a limitation Weebly has for free sites for how many embedded code elements can run on one page? 

1,421 Views
Message 14 of 13
Report

All the scripts can run fine when they are the only ones on the page. But when multiple are on the page, it bugs out.

1,418 Views
Message 14 of 13
Report

Sounds like they don't play well together. Maybe you could put them on different pages?

1,405 Views
Message 14 of 13
Report

I have everything working now. Each script was requesting an API at the same time. Now one script requests all the info and sends that info to defined <div> and <p> in the page

1,335 Views
Message 14 of 13
Report

Ah, that makes sense. Nice fix!

1,335 Views
Message 14 of 13
Report

Could you please give more detailed info about your fix?
1,294 Views
Message 14 of 13
Report
This thread has been archived and locked. Please start a new thread if you would like to continue the conversation.
grz-custom-initialLetter