SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2008
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    pass variablke from a js file to PHP

    I wish to know how a variable from a javascript file can be passed to PHP?
    Code JavaScript:
    <script type="text/javascript"><!--
    google_ad_client = "ca-pub-1234567890123456";
    /* snipet_name */
    google_ad_slot = "123456789";
    google_ad_width = 728;
    google_ad_height = 90;
    //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
    This is a google adsense script sample, and I'll like to know how are passed the id's to a server database. How are generated the links based on those id's(google_ad_client and google_ad_slot)?

    Maybe my question isn't clear just because I don't see how the service works from the programming point of view.

    PS: I don't try to replicate or to hack google adsense service but I'm curious about how it works.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Take a look at the embedded code from http://pagead2.googlesyndication.com/pagead/show_ads.js and you might spot how that js file builds a url, then, though I did not stop to figure it out fully, JS can open a new window or iframe with your google_ad_client as one of the GET arguments.

    I'd guess this is how they are doing it.


Tags for this Thread

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
  •