Backstory: I'm trying to use the Newsletter Widget from SendGrid but they currently don't offer it using SSL. So any requests to https:// just redirect to http:// and then browsers complain about insecure content on my secure site.
Ok fine, so I implement something like this in PHP:
$output = file_get_contents('http://sendgrid.com/newsletter/getSubscriptionWidget?p=xxx');
And then in my view have this:
<script type="text/javascript">
<?php echo($output); ?>
</script>
Viewing the source of this page after execution shows that it pulls the javascript widget code in just fine. BUT, it doesn't work. By "not working" I mean the javascript code never executes.
If I load it (in a non-https development environment) using the script tag like:
<script type="text/javascript" src="http://sendgrid.com/newsletter/getSubscriptionWidget?p=xxx">
Then it works just fine!
TL;DR; What would cause javascript to execute fine when loaded under the src attribute of the script element and not work when echoed as content inside script tags?
P.S. You can view the SendGrid widget source here.