Using livequery to load external javascript into a div layer
Forgive me, I'm not a UI developer at all.
I have a messy site with lots of JS/jquery, that loads the primary content for the home page from "index-ok.html" using load():
- $('#main').load('index-ok.html);
Inside index-ok.html is a div element with an id of "ad", ie:
- <div id="ad"></div>
I need to display some javascript inside of the 'ad' div, that will display some google adsense ads - just inserting the google adsense js code inside of index-ok.html absolutely does not work, so I'm trying to load it from an external file "ad.html" and replace the contents of the 'ad' div.
Here's "ad.html" :
- <div id="content_holder_nopad" style="back-ground-color:ECEEF200;">
- <center>
- <script type="text/javascript"><!--
- google_ad_client = "ca-pub-XXXXXXXXXXXXXXXX";
- google_ad_slot = "XXXXXXXX";
- google_ad_width = 728;
- google_ad_height = 15;
- google_ad_background_color = "ECEEF200";
- //-->
- </script>
- <script type="text/javascript"
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
- </script>
- </center>
- </div>
and after massive searching and reading it seems that the livequery() method is the proper way to go about this (??). So here's my final attempt:
- $('#main').load('index-ok.html', function() {
- $('#ad').livequery("load",function() {
- $(this).load('ad.html', function() {
- return false;
- });
- });
- });
My index-ok.html is getting loaded fine, but I still have no luck with getting anything at all inside of my 'ad' div....
Any help??