
Here's another cool and useful thing you can do with Ajax:
serve rotating ads. Instead of settling for a static ad on a page a user might not refresh for minutes or even hours, you can set the ads to rotate at a predetermined interval. The concept and implementation are so simple, it's a wonder this hasn't taken off more. Just put the ad inside an iframe and refresh its contents on every XHR call. (Caveat: if you're using a Strict doctype, your page won't validate, since iframes aren't valid in Strict. Perhaps there's a way to achieve the same thing using the
object element?)
1. From what I understood, they used the IFRAME because they had to. That's how Google's ads work and you aren't supposed to mess with them. Upon reading again, it seems they put the ads in an IFRAME, which seems silly since the ads are already in an IFRAME and they could do a little research to find a way to interact with Google's IFRAME.
Whatever the case, if you control what ads are shown, there is no reason you couldn't just use a DIV, make a XMLHttpRequest and replace all the content within that DIV with a new ad. This would be useful if you wanted to keep a validating STRICT page but refresh ads periodically.
However, this guy is just saying "if you ALL your requests for content are through AJAX, do this." That means your page NEVER reloads but you want your ads to change when the page content changes. I don't know many sites that do that unless they are web apps. So, the solution being proposed is for a small niche group.
Posted at 1:02PM on Aug 10th 2006 by Robert Brodrecht