在服务端返回json数据时,文件保存成utf8,json解析不了。而把文件保存成utf8无BOM就可以解析。
就因为几个用肉眼看不到的字符
case sentence_info: // 每日一句列表 $pageIndex=($_POST[pageIndex]-1)*$_POST[displayNumber]; $displayNumber=$_POST[displayNumber]; // $month=$_POST[month]; $result_num = mysql_query("select sid from i_sentence"); $total = mysql_num_rows($result_num); $total_page=ceil($total/$displayNumber); $arr=array(); $query=mysql_query("select sid,picture,picture2,content,note,browsenum,translation,tts, dateline from i_sentence where 1=1 order by dateline desc limit $pageIndex,$displayNumber"); while($row=mysql_fetch_assoc($query)) { $row[note]=urlencode(preg_replace("/(\s|\ \;| |\xc2\xa0)/","",$row[note])); $row[translation]=urlencode(preg_replace("/(\s|\ \;| |\xc2\xa0)/","",$row[translation])); // $row[imgs]=get_img($row[id]); $row[dateline]=urlencode(date('Y M d',strtotime($row[dateline]))); $picinto=pathinfo($row[picture2]); if(!empty($picinto[extension])) { $row[picture]=$row[picture2]; } unset($row[picture2]); $arr[]=$row; } $data=urldecode(json_encode($arr)); $s=mysql_errno(); //echo $data; echo "{\"s\":$s,\"data\":$data,\"total\":$total_page}"; break;
以上就是看不见的问题(个性的json)的内容,更多相关内容请关注PHP中文网(www.php.cn)!