4

A simple code like this will never work and I searched the entire of the Google, the bloody hell company does not provide a simple tutorial on how to apply the jQuery? This is very frustrating!

<Content type="html"><![CDATA[
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
   <div id="content_div" height="250">abc</div>

   <script type="text/javascript">
       alert($('#content_div').css('height'));
   </script>
   ]]>    
</Content>

What is wrong?

========

If I use this:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>

I will get this error:

enter image description here

If I use this:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>

I will get this error:

enter image description here

The error message:

[blocked] The page at https://pct0pnegjcnktlrmc1cf6dh916jdefnq-a-sites-opensocial.googleuserconte…y%252F8t2ynycEfP2AdZ8IeBvJF%26c%3Denterprise&rpctoken=-2403247092253746774 ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js.
lannyboy
  • 617
  • 1
  • 10
  • 20
  • i realized you're using google gadgets. I don't think you can load external javascript files using google gadgets, so you won't be able to use jquery. – kennypu Apr 11 '13 at 03:38

1 Answers1

3

Okay, after I read this one https://developers.google.com/speed/libraries/devguide, finally I solved this darn issue...

Instead of

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

It has to be: (the culprit is the "http" scheme)

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

So this is how it will look like:

<Content type="html"><![CDATA[
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
   <div id="content_div" height="250px">abc</div>

   <script type="text/javascript">
        $('#content_div').html('123');
   </script>
   ]]>    
</Content>
lannyboy
  • 617
  • 1
  • 10
  • 20