Pass Data To Controller Through Ajax In Code Igniter
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
Solution 1:
A useful way to manipulate data is to use json in your datatypes:
functiongetResult(billno){
var baseurl = $('.hiddenUrl').val();
$('.checkbillno').addClass('preloader');
$.ajax({
url : baseurl + 'Controller/checkBillNo/' + billno,
cache : false,
dataType: 'json',
success : function(response){
$('.checkbillno').attr('data-content', response.toolTip);
}
})
}
Now your js function expects a json encoded array as a response, so in your controller you could do something like the below:
$forToolTip = '';
foreach($query->result() as$row){
$forToolTip .= $row->key;
}
$result['toolTip'] = $forToolTip;
echo json_encode($result);
Alter variables to match your concept
Post a Comment for "Pass Data To Controller Through Ajax In Code Igniter"