title: Codeigniter ajax database lookup working on test site but not on production
body: <p>I have followed a <a href="http://vortexdev.netii.net/article_17/Check_the_user_name_availability_with___Codeigniter_jQuery" rel="nofollow">tutorial</a> on an ajax lookup that informs the user if the username is already taken. I have also done the tutorial in a localhost folder named login as per example. I have downloaded all their code and applied it. this works correctly on <code>localhost/login</code></p>
  
  <p>if I move the code across to my actual web application, <code>localhost/production</code> and adjust the syntax in the check.js file from:</p>
  
  <pre><code>url : baseurl + 'index.php/login/getResultfromdb/' + name,
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>url : baseurl + 'getResultfromdb/' + name,
  </code></pre>
  
  <p>All other code remains the same as below. </p>
  
  <p>My problem is that when the I enter data into the input field and the jquery / ajax is initiated, the result is always negative. red cross is shown as per the tutorial css. if I enter a username that is already taken it returns that it is available.</p>
  
  <p>Now I have looked for errors in my google developer tools(F12) and cant see any. the only one that did appear was the url in check.js which I corrected as above.</p>
  
  <p>My feeling is that the input value is not being fetched correctly by jquery so the database query is for a different value than the one entered. </p>
  
  <p>Could this be an issue with the config of my codeigniter? an autoload or the like? I have checked all of what I know and it appears to be correct but values are still being returned incorrectly.</p>
  
  <p>any advice is appreciated.</p>
  
  <p>The controller syntax is:</p>
  
  <pre><code>&lt;?php
      class Login extends CI_Controller
      {
          function index()
          {
              $this-&gt;load-&gt;view('loginView');
          }
          function getResultfromdb($username){
  
          $this-&gt;db-&gt;where('username',urldecode($username));
          $query = $this-&gt;db-&gt;get('users')-&gt;num_rows();
          if($query == 0 ) echo 'userOk';
          else echo 'userNo';
      }
      }
  </code></pre>
  
  <p>the view is:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Check User Name&lt;/title&gt;
          &lt;link type="text/css" rel="stylesheet" href="&lt;?=base_url()?&gt;css/style.css"/&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;form method="post" action=""&gt;
  
              &lt;label for="username"&gt;Enter Your Name&lt;/label&gt;
              &lt;input type="text" id="username"/&gt;
              &lt;span class="checkUser" &gt;&lt;/span&gt;
              &lt;input type="hidden" class="hiddenUrl"/&gt;
          &lt;/form&gt;
  
          &lt;script type="text/javascript" src="&lt;?=base_url()?&gt;js/jquery-1.6.2.min.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="&lt;?=base_url()?&gt;js/check.js"&gt;&lt;/script&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>the check.js is:</p>
  
  <pre><code>$(document).ready(function(){
  
      $('#username').blur(function(){
  
          if( $('#username').val().length &gt;= 3 )
              {
                var username = $('#username').val();
                getResult(username); 
              }
          return false;
      })
      function getResult(name){
          var baseurl = $('.hiddenUrl').val();
          $('.checkUser').addClass('preloader');
          $.ajax({
              url : baseurl + 'getResultfromdb/' + name,
              cache : false,
              success : function(response){
                  $('.checkUser').removeClass('preloader');
                  if(response == 'userOk') $('.checkUser').removeClass('userNo').addClass('userOk');
                  else $('.checkUser').removeClass('userOk').addClass('userNo');;
              }
          })
      }
  })
  </code></pre>
  
  <p>As mentioned, this works great on my localhost/login but not on my localhost/production?</p>