Is it possible to use ajax to deliver ad content to publishers of an ad network

106 views Asked by At

I'm developing an ad network for my project.

Is it possible to use ajax to deliver ad content to publishers of an ad network ?

I already know google uses document.write or something similar like this.

document.write('<iframe src="http://myadserver.com/showads.php?ad_client='+ ad_client+'&ad_slot='+ad_slot+' margin=0 frameborder=0 scrolling=no allowtransparency=true ></iframe>');

But what about ajax ?

Can I use ajax to deliver ad content to the publishers on my ad network ?

1

There are 1 answers

3
eirasf On BEST ANSWER

You sure can. Just import some JS file into your document and have it alter your page to display your ad. First load the file, with whatever parameters you choose to indicate what ad to load, the container name or whatever you need. You should also provide a callback function for the script to call once loaded that displays the ad.

function changeAd(adURL)
{
   adContainer.innerHTML="<img src=\""+adURL+"\" />";
}
var adScript = document.createElement("script");
    adScript.type = "text/javascript";
    adScript.src = "http://yoursite/adScript.js?someparam=1";
document.head.append(adScript);

The contents of adScript should just call changeAd with the URL to your ad.

changeAd("http://yoursite.com/ads/fancyad.jpg");