Passing and getting hyperlinks into a single JQuery function
<p>What I would like to do is to take several links that may be on a page and send only the link that was clicked on to a PHP script to be parsed.</p>

<pre><code>&lt;a href="?something=2&amp;id=100&amp;somethingelse=55" class="link"&gt;My First Link&lt;/a&gt;
&lt;a href="?something=3&amp;id=400&amp;somethingelse=65" class="link"&gt;My Second Link&lt;/a&gt;
</code></pre>

<p>What I would like is to grab the link and have it passed to PHP. Using this code, I am only ever able to get the first link, no matter which link I click on.</p>

<p>I'd rather have one function to send these links into than a function for each and every hyperlink I have in the site. I'm simply trying to condense or consolidate the amount of functions needed that basically do the same thing.</p>

<p>Here is what I have so far:</p>

<pre><code>  $(".link").click(function() {
  var v1 = $("a.link").attr("href");

//    var v1 = $("a.ajax-link")[2].href;
    var dataString = 'v1='+ v1;

    $.ajax({
      type: "POST",
      url: "/",
      data: dataString,
      dataType: 'json',
      success: function(data) {
        if(data.success == 1){
          alert(data.success);
        }
        else{
          alert(data.success);
        }
      }
    });
    return false;
  });
</code></pre>
