title: ajax php GET/POST without refresh
body: <p>I need to execute the following code, without refreshing the page... this code already includes ajax but where am I going wrong with getting it to execute without refreshing the page....? the .vote class is attatched to an anchor in my index.php file, and I need this all to still work when the anchor is clicked if possible. Re-coding this to perform on a button click would not be ideal.</p>
  
  <pre><code>$(".vote").click(function() {
      var id = $(this).attr("id");
      var name = $(this).attr("name");
      var eData = $(this).attr("data-options");
      var dataString = 'id='+ id + '&amp;' + eData ;
      var parent = $(this);
  
      if(name=='up')
      {
         $(this).fadeIn(200).html('');
         $.ajax({
            type: "POST",
            url: "up.php",
            data: dataString,
            cache: false,
            success: function(html){
               parent.html(html);
            }
         });
      }
      else
      {
         $(this).fadeIn(200).html('');
         $.ajax({
            type: "POST",
            url: "down.php",
            data: dataString,
            cache: false,
            success: function(html){
               parent.html(html);
            }
         });
      }
  });
  </code></pre>
  
  <p>here is the html from my index.php</p>
  
  <pre><code>&lt;div id="main"&gt;
  &lt;div id="left"&gt;
  &lt;span class='up'&gt;&lt;a href="" class="vote" name="up" data-options="key1=&lt;?php echo $mes_id1;?&gt;&amp;key2=&lt;?php echo $mes_id2;?&gt;"&gt;&lt;img src="up.png" alt="Down" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
  &lt;?php echo $totalvotes1; ?&gt;&lt;br /&gt;
  &lt;/div&gt;
  &lt;div id="message"&gt;
      &lt;?php echo $message1; ?&gt;
  &lt;/div&gt;
  &lt;div class="clearfix"&gt;&lt;/div&gt;
   &lt;/div&gt;
  &lt;div id="main"&gt;
  &lt;div id="right"&gt;
  &lt;br /&gt;
  &lt;?php echo $totalvotes2; ?&gt;&lt;br /&gt;
  &lt;span class='down'&gt;&lt;a href="" class="vote" name="down" data-options="key1=&lt;?php echo $mes_id1;?&gt;&amp;key2=&lt;?php echo $mes_id2;?&gt;"&gt;&lt;img src="down.png" alt="Down" /&gt;&lt;/a&gt;&lt;/span&gt;
  &lt;/div&gt;
  &lt;div id="message"&gt;
      &lt;?php echo $message2; ?&gt;
  &lt;/div&gt;
  &lt;div class="clearfix"&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>