title: JS: Changing this function to handle a link click
body: <p>Following the example here <a href="http://blog.theonlytutorials.com/very-simple-jquery-and-php-ajax-request-ready-to-use-code/" rel="nofollow">Very Simple jQuery and PHP Ajax Request – Ready to use code</a></p>
  
  <p>I've been successful in creating a drop down list that passes the value to an external PHP script and returns the HTML output back to a "div" on the same page and it works great. </p>
  
  <p>What I want to do now is post values when I click on link instead of building a drop down list.  So ...if I created this link:</p>
  
  <pre><code>&lt;a href="foo.php?route_number=2"&gt;Route Number 2&lt;/a&gt;
  </code></pre>
  
  <p>I want "2" passed to that external PHP script and the content changed on the " div " as it currently works with the dropdown. I don't know how to change the javascript to handle this or what "foo.php" really needs to be.</p>
  
  <p>Here's the current javascript from that example:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $('#route_number').click(function() {
              routenumber = $('#route_number').val();
              $.post('api.php', { route_number : routenumber }, function(res) {
                  $("#mainlayer").html(res);
              });
           });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>And here's what the dropdown portion of the HTML looks like:</p>
  
  <pre><code>    &lt;select name="route_number" id="route_number"&gt;
      &lt;option value="notchosen"&gt;Please Choose A Route&lt;/option&gt;
      &lt;option value="2"&gt;Riverfront&lt;/option&gt;
      &lt;option value="11"&gt;Magazine&lt;/option&gt;
      &lt;option value="16"&gt;Claiborne&lt;/option&gt;
      &lt;/select&gt;
      &lt;div id="mainlayer"&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>So, to be clear, instead of a dropdown that passes values, I want to create links that accomplish the same result.</p>
  
  <p>Thanks in advance,</p>
  
  <ul>
  <li>dan -</li>
  </ul>