在json代码igniter中从控制器检索数据 [英] retrieve data from controller in json code igniter
本文介绍了在json代码igniter中从控制器检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(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);
}
})
}
})
我的控制器
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)));
}
如何在span中输出值类文本从控制器得到的值..我已经检查firebug在其中响应选项卡我成功获得我的结果,但如何在我的视图页面中打印span类..
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 ..
推荐答案
您需要获得 objet.parameter
的响应,如下所示:
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:
这是回应{result:142}
this is the response {"result":"142"}
这篇关于在json代码igniter中从控制器检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文