title: AJAX call using the last variable loaded on the page instead of current post
body: <p>I'm creating a custom plugin that fires a ajax call when they sharing the post on twitter, Google + or liking it on Facebook.</p>
  
  <p>Within the index.php file I put this inside the loop so it gets called on every new post on the home page.</p>
  
  <pre><code>&lt;?php cp_social_sharing_4pts(); ?&gt;
  </code></pre>
  
  <p>Here part of my PHP function:</p>
  
  <pre><code>function cp_social_sharing_4pts(){
  if ( is_user_logged_in() ) {
   echo '&lt;script type="text/javascript"&gt;
   var postid = '.get_the_ID().';
   function cp_share_twitter_do(){
   jQuery.ajax({dataType: "json", data: {action: "cp_share_twitter_do", post: postid},
    success: function(data){
    if(data.success==true){
    Boxy.alert(data.message);
    thebox.hide();
    thebox.unload();
   } else { Boxy.alert(data.message); }
   }
   });
  }
  &lt;/script&gt;
  ';
  }
   // Show Buttons
   echo 'Post ID: '.get_the_ID().'&lt;br /&gt;'; // debug
  echo '&lt;a href="https://twitter.com/share" class="twitter-share-button" data-    url="'.get_permalink().'" data-text="'.get_the_title().'" data-count="horizontal" data-     via="ps3blogdotnet"&gt;Tweet&lt;/a&gt;'; 
  }
  </code></pre>
  
  <p>Then this gets loaded into the head:</p>
  
  <pre><code>function cp_social_sharing_js(){
   if ( is_user_logged_in() ) {
  echo '
  &lt;script type="text/javascript" src="http://platform.twitter.com/widgets.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  twttr.events.bind(\'tweet\', function(event) { cp_share_twitter_do(); });
  &lt;/script&gt;
  ';
   }  
  }
  add_action('wp_head','cp_social_sharing_js');
  </code></pre>
  
  <p>After the AJAX fires it goes here:</p>
  
  <pre><code>    function cp_share_twitter_do(){ // Tweet Entry
              $cp_postID = $_POST['post']; // THIS IS THE ISSUE. It's not returning the correct ID from the post I shared on.
      // Do more functions here
      echo json_encode($r);
      die();
  }
  add_action('wp_ajax_cp_share_twitter_do', 'cp_share_twitter_do');
  </code></pre>
  
  <p>This does work perfectly if on a single blog post. The issue is on the home page. </p>
  
  <p>The variable <strong>postid</strong> does correctly display the post ID on each post. But when the ajax call completes it always passes the post id of the last post displayed on the home page instead of the current post.</p>