title: pass data to controller through ajax in Code igniter
body: <p>i am beginner in a  code igniter and jquery. i have a textbox in which if user type some thing it displays the data in tooltip from the database.. here in my situation what i want is ... i have a texbox named called "bill no".. what i want is if a user enter bill no in a text box it displays the data against the bill no.. i dont know how can i pass data from controller to view in ajax and then after pass how to show in tooltip
   here is my code</p>
  
  <pre><code>Bill No:&lt;?php echo form_input($bill_no); ?&gt;
  &lt;input type="hidden" class="hiddenUrl"&gt;&lt;span class="checkbillno" data-trigger="manual"
  
  
       data-title="bill no" data-content="here i want to display results"&gt;&lt;/span&gt; 
  </code></pre>
  
  <p>my javascript </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(document).ready(function(){
  
          $('#bill_no').blur(function(){
  
              if( $('#bill_no').val().length &gt;= 3 )
                  {
                    var bill_no = $('#bill_no').val();
                    getResult(bill_no); 
                  }
              return false;
          })
          function getResult(billno){
              var baseurl = $('.hiddenUrl').val();
              $('.checkbillno').addClass('preloader');
              $.ajax({
                  url : baseurl + 'Controller/checkBillNo/' + billno,
                  cache : false,
                  success : function(response){
                      $('.checkbillno').removeClass('preloader');
                      if(response == 'userOk')
                          $('.checkbillno').removeClass('preloader');
                      if(response == 'userOk') $('.checkUser').removeClass('userNo').addClass('userOk');
                      else $('.checkUser').removeClass('userOk').addClass('userNo');
  
                  }
              })
          }
      })
  </code></pre>
  
  <p>here what i am doing is that it simply check the bill no in database and if it is available in the database then it adds the class "userok" otherwise "userfalse".. and here what i want is display data as well as against the bill no..i know how to do this in model but dont know how can i pass from controller to ajax and then it shows the result in tooltip</p>
  
  <p>my controller</p>
  
  <pre><code>function checkBillNo($billno){
      $this-&gt;load-&gt;model('returnModel');
      $query = $this-&gt;returnModel-&gt;checkBillNo($billno);
  
      if($query == 1 ) 
          $data['result'] = $query; //how can i pass this result into view in tooltip... (span class)
  
      else 
          echo 'userNo';
  
  }
  </code></pre>