title: I want to redirect a controller with AJAX in codeigniter
body: <p>I am trying to handle a 'NEXT' button on a webpage. </p>
  
  <p>My Need: When the user clicks on the 'Next' button, the requested url posts with using a JQuery AJAX call to a function in the controller: <code>testurlredirect()</code>. This function determines the next URL.</p>
  
  <p>This is what I've tried:</p>
  
  <p><strong>My controller</strong> function is:</p>
  
  <pre><code>public function testurlredirect(){
    redirect("mycontrollername");
  } 
  </code></pre>
  
  <p><strong>My jquery</strong> code in view is:</p>
  
  <pre><code>$("#next").click(function(){
    $.post("&lt;?php echo 'http://www.domain.com/testapp/testurlredirect';?&gt;",
    {
      name:"testname",
      city:"mycity"
    },
    function(data,status){
      alert("Data: " + data + "\nStatus: " + status);
    });
  });
  </code></pre>
  
  <p>I also check this URL by echoing "hello" in b/w the function, but this message appears when I directly pasted it in a browser. When I handle the click this message does not appear in console. It just show sthe link in red color (acts like an error).</p>
  
  <p>Can you please tell me what I'm missing, or doing wrong?</p>