title: Changing the data in URL strings - Using API for database requests
body: <p>Using an API I am creating a forum using Javascript. </p>
  
  <p>When a user clicks on the thread title on the <code>index.html</code> page they are taken to a page called <code>thread.html</code> on here I am using an API call to display the results for the thread with ID 1</p>
  
  <pre><code>var threadRequest = new Request.JSON({
    url: 'control.php?action=getThread&amp;id=1',
    onSuccess: threadSuccess
      }).send();
  </code></pre>
  
  <p>My question is how would I change this so it knows which thread has been clicked so it knows which thread to call, I have tried</p>
  
  <pre><code>function callThread(thread){
    var threadRequest = new Request.JSON({
      url: 'control.php?action=getThread&amp;id='+thread,
      onSuccess: threadSuccess
       }).send();
  }
  </code></pre>
  
  <p>with <code>thread</code> being the foreign key in the table linked to the API.</p>
  
  <p>The thread titles are displayed like so</p>
  
  <pre><code>var jsonRequest = new Request.JSON({
      url: 'control.php?action=getThreadList',
      onSuccess: ajaxSuccess
  
  }).send();
  </code></pre>
  
  <p>This is the threadSuccess function as well</p>
  
  <pre><code>function threadSuccess (jArray){
      jArray.each(function(post){
          var postObject = new PostItem(post.id, post.name, post.comment, post.thread);
          postObject.display().inject($('postList'));
      })
  }
  </code></pre>
  
  <p>My question is do you get it so that the url string would do something like <code>url: 'control.php?action=getThread&amp;id=what ever number thread the user has clicked on</code></p>
  
  <p>The post table contains the fields id, name, comment, timestamp and thread (this will define which thread the post will be in.)</p>
  
  <p>and a thread table contains id and title.</p>