title: Cannot call function from click event
body: <p>I have a car parts classified section, I want to display only 10 ads per page and pagination links at bottom. Every example of PHP pagination I see puts the php code into the same page where the data is displayed....I do not want to do this. I want everything to go through jquery and AJAX and use the XMLHttpRequest to push the data on page. </p>
  
  <p>In my PHP script I put together the pagination links and each anchor has an attribute of "href='#'"  and'linkValue' who's value is dynamically set to it's corresponding page number. The PHP generates this HTML:</p>
  
  <pre><code>&lt;a class="paginateLink" linkvalue="2" href="#""&gt;&lt;/a&gt;
  </code></pre>
  
  <p>For instance when clicking on link with 'linkValue=2' that value is passed to a jquery function and concatenated to the end of the query string: </p>
  
  <pre><code>'getParts.php?pageNum=2'. 
  </code></pre>
  
  <p>The PHP script gets the value of pageNum from the query string and uses it to determine which page is returned, in this example it would return records 11-20. The parts classified page is initially loaded by a function call to 'showParts()' in the head:</p>
  
  <pre><code>$(document).ready(showParts() );
  </code></pre>
  
  <p>which in turn calls the PHP script 'getParts.php'.</p>
  
  <p>The problem is this:
  I cannot seem to call the 'showParts()' function from the click event from the pagination links. I can call a simple alert quite easily, I can even call a function which has the alert in it,but when trying to call the showParts function I just get the '#' at the end of the url addy and go to top of the page.</p>
  
  <p>The jquery function:</p>
  
  <pre><code>$(document).ready(function(){
      $(".paginateLink").click(function(){
          showParts();
      });
  });
  </code></pre>
  
  <p>At this point I'm not even trying to put the query string together, just want to get it so the function fires in the first place, even if it just sends back the same results.</p>
  
  <p>EDIT:
  Not sure what I'm doing wrong here, this seems like it should work. For instance the following code works:</p>
  
  <pre><code>$(document).ready(function(){
      $(".paginateLink").click(function(){
          alert($(this).attr('linkValue'));
      });
  });
  </code></pre>
  
  <p>So I CAN call a function and pass the necessary variable, I just can't call the showParts function, at least not a second time. Again the function is called when the page loads initially to populate the page with car parts.</p>
  
  <pre><code>function showParts(str) {
      if (str=="") {
          document.getElementById("partsDisplay").innerHTML="";
          return;
      }
      if (window.XMLHttpRequest) {
          // code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
      } else {  // code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      xmlhttp.onreadystatechange=function() {
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
              document.getElementById("partsDisplay").innerHTML=xmlhttp.responseText;
              $(document).foundation('accordion', 'reflow');
              $(document).foundation();
          }
      }
      xmlhttp.open("GET","PHP/getParts2.php",true);
      xmlhttp.send();
  }
  </code></pre>