A few months ago I was faced with a bit of a problem.  A webpage I was writing was AJAX-based - meaning that it sent requests to and from the server asynchronously and would rewrite parts of the page as the server responded.  However if the server returns any kind of scripting code (including javascript) this code is not executed as typically the javascript code to rewrite part of the page looks something like this:

document.getElementById(tagid).innerHTML =httpRequest.responseText;

All it is doing is replacing some text.  Of course if you know the name of the function you wish to execute you could check and execute it straight after, but often the script is inline anyway so you can’t just call it nilly willy.  This very much applies to Google AdSense adverts or Google Analytics, etc  - if your AJAX returns Google AdSense adverts then they will not display.

The easiest way around this is to place parts of the script inside an iframe.  Obviously the iframes have their own src attribute as they are sourced from another file.  Perhaps your AJAX call might return the following:

<iframe src='ad468x60.html' width=468 height=60 frameborder=0 scrolling=no marginwidth=0 marginheight=0></iframe>

Then inside ad460×60.html you would have the script that you wish to be executed - of course this may not be a helpful solution if you need the script to work with data already on the page or interact with something outside the iframe.  So far as Google Ads go though they are clever enough to put the right adverts on the right page, even without seeding your ad468×60.html with keywords and meta tags.

Anyway, without any border or scrolling mechanism the iframe just looks like a normal part of the page.  Typically what I do is put the iframe inside a <div> tag and float it right with a margin so that any text there is will flow around the Google Ad it:

<div style="float: right; margin: 4px"><iframe src='ad468x60.html' width=468 height=60 frameborder=0 scrolling=no marginwidth=0 marginheight=0></iframe></div>

A word of warning though.  Don’t attempt to refresh adverts on your main page through a javascript call, ie, it is one thing to return the ads in the server result, but another thing entirely to recall the google ad code on your main page (ie, rotating ads every 30 seconds or on an AJAX update call), as that breaches their TOS.  Returning Adsense code inside AJAX isn’t strictly supported by google but I have seen an example (somewhere on the google site) where they do something similar

Related posts
Google Maps’ new street level tool shows a house on fire
How to keep web addresses on one line of an email
Reduce the “Looking up” time to speed up your browser
Useful Firefox extensions
Linux: Bash Scripting: Search Bash History