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
Bill No:<?php echo form_input($bill_no); ?>
<input type="hidden" class="hiddenUrl"><span class="checkbillno" data-trigger="manual"
data-title="bill no" data-content="here i want to display results"></span>
my javascript
<script type="text/javascript">
$(document).ready(function(){
$('#bill_no').blur(function(){
if( $('#bill_no').val().length >= 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');
}
})
}
})
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
my controller
function checkBillNo($billno){
$this->load->model('returnModel');
$query = $this->returnModel->checkBillNo($billno);
if($query == 1 )
$data['result'] = $query; //how can i pass this result into view in tooltip... (span class)
else
echo 'userNo';
}