SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist perpetual_dream's Avatar
    Join Date
    Nov 2005
    Location
    Jerusalem
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Load adsense ads using AJAX

    Hello,
    When I try to get an adsense ad script using Ajax it doesn't show up... Why?

    This is my code:

    Code:
    function beginajax()
    {
    
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      } 
    var url="ads.php";
    
    
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    } 
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4)
    { 
    document.getElementById("Google-Ads").innerHTML=xmlHttp.responseText;
    
    }
    }
    How Can I do it?
    Tanzeelnet - Best arabic downloadsite
    Linux Hosting |Free Downloads |

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by perpetual_dream View Post
    Hello,
    When I try to get an adsense ad script using Ajax it doesn't show up... Why?
    When you replace the innerHTML of an element with some text that happens to include JavaScript, nothing tells the browser to parse and execute that text, so the JavaScript is not run.

  3. #3
    SitePoint Evangelist perpetual_dream's Avatar
    Join Date
    Nov 2005
    Location
    Jerusalem
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I Tell the browser to execute The Javascript?
    Tanzeelnet - Best arabic downloadsite
    Linux Hosting |Free Downloads |


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •