Dynamically refreshing ads usually is not allowed with ad networks, since it can be abused to inflate adviews. For example, look at the AdSense policy:
https://support.google.com/adsense/bin/answer.py?hl=en&a...
"Any method that artificially generates clicks or impressions on your Google ads is strictly prohibited. These prohibited methods include, but are not limited to, repeated manual clicks or impressions, automated click and impression generating tools and the use of robots or deceptive software. "
Whether or not using javascript falls under the category of "impression generating tools" is probably open for discussion, but I wouldn't be surprised if Google didn't like this.