日期:2014-05-17  浏览次数:21621 次

为什么json在ie上输入中文查询的结果不显示,但在火狐、谷歌上又可以??
为什么json在ie上输入中文查询的结果不显示,但在火狐、谷歌上又可以??
查询是没问题,因为当输入数字时,就显示数据,而中文是查询到数据,调试也看到数据保存在json 里面了,但问题就是我展示在页面上?请各位高手帮忙解决一下,在此先谢谢各位了!
  查询数据,通过json_encode()public function ajaxloadAction(){
$rsName=$this->verify_str($this->_request->getParam('rsName'));
$rsPhone=$this->verify_str($this->_request->getParam('rsPhone'));
$rsAddress=$this->verify_str($this->_request->getParam('rsAddress'));
$rsAge=$this->verify_str($this->_request->getParam('rsAge'));

$responsibleModel=new ResponsibleModel();
$srArray=$responsibleModel->getquery($rsName,$rsPhone,$rsAddress,$rsAge);
//print_r($srArray);//$srArray=$this->getAllList($responsibleModel);
// print_r($srArray);
 
echo json_encode($srArray);

}

在页面调用json
$.getJSON(url, function(json){
alert(json.length);
if(json.length !=0){
$(tab_id).empty();
$.each(json,function(i,responsible){
str +="<tr><td width='36' align='center'><input name='checkall' id='"+responsible.id+"' type='checkbox' title='"+responsible.responsible_name+"' onclick='select()' value='"+responsible.id+"' >"+
"</td><td width='60'>"+responsible.responsible_name+"</td>"+
"<td width='100'>"+responsible.responsible_phone+"</td>"+
"<td>"+responsible.responsible_address+"</td></tr>";
});
$(tab_id).append(str);
}else{
alert("没有你想要查询的数据!");
}
});

------解决方案--------------------
估计是编码的问题
------解决方案--------------------
alert(json.length); 时是否有值?
alert(json); 看到什么?
------解决方案--------------------
那你换个低版本的 IE 看看
可能是 IE9 不支持你的代码
------解决方案--------------------
我以前也有这个情况。、、、

很无解。……


------解决方案--------------------
html php 都保存为utf8格式的。。。注意别有bom
------解决方案--------------------
输出的字符串格式问题,在js里转换成json格式,或者中文编码问题,用''标志中文值。