title: AJAX call by anchor ID
body: <p>I'm building a Codeigniter app that utilizes AJAX with jQuery.  In one of my views, I have:</p>
  
  <p><strong>views/users/index.php</strong></p>
  
  <pre><code>&lt;?php echo anchor('users/edit', 'Edit Profile', array(
      'class' =&gt; 'user-link', 
      'id' =&gt; 'edit'
  ));?&gt;
  
  &lt;?php echo anchor('users/private_messages', 'Private Messages', array(
      'class' =&gt; 'user-link', 
      'id' =&gt; 'private_messages'
  ));?&gt;
  
  &lt;div id="ajax-loader"&gt;&lt;img src="&lt;?php echo base_url();?&gt;img/loading.gif"/&gt;&lt;/div&gt;
  &lt;div id="result"&gt;&lt;/div&gt;
  
  &lt;script type="text/javascript"&gt;
  $(function(){
      $('.user-link').click(function(event) {
          event.preventDefault();
          $.ajax({
              url: $(this).attr('href'),
              type: 'POST',
              async: true,
              beforeSend: function(){
                  $('#result').hide();
                  $('#ajax-loader').show();
              },
              error: function(xhr, status, thrown){
                  alert(xhr + ',' + status+ ',' + thrown);
              },
              complete: function(){
                  $('#ajax-loader').hide();
              },
              success: function(data) {
                  $('#result').empty().append(data);
                  $('#result').fadeIn('slow');
              }
          });
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>This works fine, it grabs the <code>href</code> value of each anchor and loads a method on click.  Now what I'd like to do is have the ability to load a method with AJAX by visiting the the <code>id</code> of an anchor, for example if I visit </p>
  
  <p><a href="http://appdomain.com/users/index#edit" rel="nofollow">http://appdomain.com/users/index#edit</a></p>
  
  <p>I want to grab the <code>href</code> value of that anchor and call it with AJAX.  The reasoning behind this is that I have a few redirects set up within the <code>Edit</code> controller that point to <code>users/index</code> and I need to load the method again with AJAX after refresh, so I was thinking something like:</p>
  
  <p><code>redirect(users/index#edit)</code></p>
  
  <p>Is this practical?  I need a method of initiating an AJAX call to a specific method on page load.  Any suggestions would be much appreciated. </p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>Grabbing the hash value with Javascript then checking it seems to work:</p>
  
  <pre><code>var hash = window.location.hash;
  var id = hash.substring(0);
  if(id == '#edit' || id == '#private-messages'){
      $.ajax({
          url: $(id).attr('href'),
          type: 'POST',
          async: true,
          beforeSend: function(){
              $('#result').hide();
              $('#ajax-loader').show();
          },
          error: function(xhr, status, thrown){
              alert(xhr + ',' + status+ ',' + thrown);
          },
          complete: function(){
              $('#ajax-loader').hide();
          },
          success: function(data) {
              $('#result').empty().append(data);
              $('#result').fadeIn('slow');
          }
      });
  }
  </code></pre>