title: Parsing url with javascript for codeigniter uri value
body: <p>I've come across a situation where I would appreciate some help with.</p>
  
  <p>I have a controller called Site with a function as follows:</p>
  
  <pre><code>function getID(){
      $id_data = $this-&gt;uri-&gt;segment(3);
      $name = $this -&gt; session -&gt; userdata('name');
      echo json_encode($this -&gt; getID_model -&gt; getID($id_data,$name ));
  }
  </code></pre>
  
  <p>my url looks as follows</p>
  
  <pre><code> http://myapp.com/index.php?/site/user/96
  </code></pre>
  
  <p>when the link is opened the user is able to see his page only when the User function has ran my checks. This is why I can not remove or alter the User function since it needs to read the URI data and needs to be kept separate from my getID function </p>
  
  <p>Now here is where my question comes in.</p>
  
  <p>I need to make a call to the getID function in the Site controller and it needs the 3rd URI id number.</p>
  
  <p>Below is my JQuery</p>
  
  <pre><code>    var fullurl = $('#hiddenurl').val() + 'index.php?/site/getID/';
  
  $.getJSON(fullurl, function(json) {
      $.each(json, function(i,d) {
          //do my output stuff.
      });
      $('#_description').append(output);
  });
  </code></pre>
  
  <p>This won't work because the controller expects a 3rd URI segment.</p>
  
  <p>Can someone tell me how I should add this segment in to the url? should I use some sort of JS parsing?</p>
  
  <p>Thank you.</p>