Ajax 问题
本帖最后由 shugong 于 2013-9-6 18:12 编辑CI新手求教
function car_check(){
$id = $this->input->get('id');
$da['carnum'] = $this->input->get('carnum');
$da['color']= $this->input->get('color');
header("Content-Type:text/html;charset=gbk");
header("Cache-Control:no-cache");
$info="";
if($da['carnum'] == '')
{
$info= '{"res":" "}';
}
else{
$res = $this->Mgate->edit_car_by_id($id, $da);
if($res){
$info= '{"res":"已核对"}';
}
else{
$info= '{"res":"数据库出错"}';
}
}
echo $info;
}
控制器
function chuli(){
if(myXmlHttpRequest.readyState==4){
var mes=myXmlHttpRequest.responseText;
window.alert(mes);
}
}
ajax
alertHTML代码怎么去除呢
有高手能看下吗{:soso_e150:} 你想前端返回的数据格式是什么样?json ???
function car_check(){
$id = $this->input->get('id');
$da['carnum'] = $this->input->get('carnum');
$da['color']= $this->input->get('color');
header("Content-Type:text/html;charset=gbk");
header("Cache-Control:no-cache");
$info="";
if($da['carnum'] == '')
{
$info= '{"res":" "}';
}
else{
$res = $this->Mgate->edit_car_by_id($id, $da);
if($res){
$info= '{"res":"已核对"}';
}
else{
$info= '{"res":"数据库出错"}';
}
}
echo $info;
die();
} 对是JSON 但是后面有一大堆HTML代码怎么除去 这是你开启了评测器造成的 car_check() 这个方法里加
$this->output->enable_profiler(FALSE); xb0726 发表于 2013-9-8 07:46 static/image/common/back.gif
car_check() 这个方法里加
$this->output->enable_profiler(FALSE);
还真是!非常感谢!
页:
[1]