Cloud 9 newbie question: JS not functioning


#1

I loaded in a draft of a project that runs fine when I test from Coda, etc. but for some reason in spite of my .js library being linked correctly, I can’t get it to recognize the .js files. None of them are being applied to the Preview. The .css is being called in fine as are images.

Links to JS are simply:

It’s a straight up HTML page. Nothing that complicated. I am currently running it using the Apache server with contextual links to the files. Yet my preview won’t show the .js functioning. I’m probably doing something wrong here. Am I missing a step or needing to run something to put them into play? Thanks for your help!


#2

Are you trying to run it in the Preview inside of Cloud9? Or is this popped out into another tab? If it isn’t, can you try pressing the Pop out button at the top right of the preview and seeing if it works in that?


#3

Popping out didn’t help. I’m testing this before i put the project in play and it should just be a simple one-page HTML with some js and css. The preloader won’t move on and the other functions won’t work but when I use it in a browser outside of C9, it works perfectly.

I might be doing something wrong, but I am deeply perplexed. Here’s the public URL: https://ide.c9.io/shanelukasux/sai-inbrace - I am not sure if you can see it.


#4

On line 18 and line 26 of index.html, you try to load a font and jQuery, respectively. These references are to HTTP resources, but the preview is loaded over HTTPS, throwing a ton of errors related to jQuery being undefined. Here are the lines of code, but corrected:

Line 18: <link href='//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700' rel='stylesheet' type='text/css'>
Line 26: <script src="//code.jquery.com/jquery-latest.js"></script>

By changing the http:// to // it will use the protocol the page was loaded over (HTTPS in this case) and should fix those errors. The rest should work at that point. The reason it works in other places but not Cloud9 is just because Cloud9 requires you to use HTTPS.


#5

dannytech - my hero :slight_smile: thank you!. I did not know it required secure server protocol from Cloud 9. Thanks for sharing that and the solutions. I will keep that in mind from here on out.