分组模式Action调用父类Action函数时,AjaxReturn自动添加BOM头

浏览:997 发布日期:2012/03/05
- 普通 - 未处理
我分了两个组,Admin和Home,在Lib目录下放了QueryAction.class.php,其中有这么一个函数

public function ajaxGetIterm()
{
$id = $_REQUEST['id'];
$iterm = M('iterm');
$result = $iterm->where('id='.$id)->limit(1)->select();
if($result)
$this->ajaxReturn($result[0],"查询成功!",1);
else
$this->ajaxReturn($result[0],"查询失败!",0);
}


在Admin中建立AdminQueryAction.class.php,代码如下

class AdminQueryAction extends QueryAction
{
}

然后在页面中使用Ajax:
[backcolor=rgb(255,255,255)]$.post("/tengfei/index.php/Admin/AdminQuery/ajaxGetIterm", {id:64}, function(data){console.log(data)},'json')[/backcolor]
[backcolor=rgb(255,255,255)]在IE和Webkit下会出现错误,然而[/backcolor]
[backcolor=rgb(255,255,255)]如果不使用继承,直接在AdminQueryAction中写函数[/backcolor]
[backcolor=rgb(255,255,255)]。如:[/backcolor]
[backcolor=rgb(255,255,255)]class AdminQueryAction extends Action
{
public function ajaxGetIterm()
{
$id = $_REQUEST['id'];
$iterm = M('iterm');
$result = $iterm->where('id='.$id)->limit(1)->select();
if($result)
$this->ajaxReturn($result[0],"查询成功!",1);
else
$this->ajaxReturn($result[0],"查询失败!",0);
}
}[/backcolor]
[backcolor=rgb(255,255,255)][/backcolor]
[backcolor=rgb(255,255,255)]则不会有任何问题[/backcolor]
[backcolor=rgb(255,255,255)][/backcolor]
[backcolor=rgb(255,255,255)]经过仔细检查,发现前一种方法返回的json在头部添加了BOM信息ef bb bf,其他方面别无二致。[/backcolor]
[backcolor=rgb(255,255,255)][/backcolor]
[backcolor=rgb(255,255,255)]也许是我个人的问题,谢谢。[/backcolor]
评论(
后面还有条评论,点击查看>>