Reputation: 175
$(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();
// $('.checkUser').addClass('preloader');
$.ajax({
url : baseurl + 'returnFromCustomer_Controller/checkBillNo/' + billno,
cache : false,
dataType: 'json',
success : function(response){
$(".text").prepend(response.text);
}
})
}
})
my controller
function checkBillNo($billno){
$this->load->model('returnModel');
$query = $this->returnModel->checkBillNo($billno);
header('Content-Type: application/x-json; charset=utf-8');
echo(json_encode($this->returnModel->sale($billno)));
}
how can i print the value in span class "text" after getting the values from controller.. i have checked in firebug in which in response tab i am successfully getting my result but how can i print in my view page in span class ..
Upvotes: 0
Views: 1732
Reputation: 8528
you need to get the response as objet.parameter
like this:
success : function(response)
{
$(".text").html(response.result);
}
Because as you said in your comment:
this is the response {"result":"142"}
Upvotes: 2
Reputation: 19882
You can use segment no to retrieve the parameter from url
function checkBillNo($billno)
{
$this->load->model('returnModel');
$query = $this->returnModel->checkBillNo($billno);
$billno = $this->uri->segment(3);
$billno_results = $this->returnModel->sale($billno)
//header('Content-Type: application/x-json; charset=utf-8');
echo json_encode($billno_results);
}
What is the use of $query here. Also you dont need to set header type
ANd your ajax here
$.ajax({
url : baseurl + 'returnFromCustomer_Controller/checkBillNo/' + billno,
cache : false,
dataType: 'json',
success : function(response){
$(".text").prepend(response);
}
})
See you dont need response.text simple print response
Upvotes: 0