求助!!php+ajax+ json 问题 本帖最后由 zl2727 于 2013-12-10 18:08:23 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Array ( [0] => Array ( [id] => 1 [goodstitle] => 琛ユ按娑﹁偆鑶� 鐪熺殑寰堝ソ 寰堣ˉ姘� 鐨偆鏈夊脊鎬� [goodsurl] => http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg [brandtitle] => 缇庡疂鑾� [brandurl] => http://www.ecoo.com.cn/dsadasdas/ [imgurl] => http://www.ecoo.com.cn/sadas213/ [price] => 59.9 ) [1] => Array ( [id] => 2 [goodstitle] => 琛ユ按娑﹁偆222 [goodsurl] => http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg [brandtitle] => 缇�222 [brandurl] => http://www.ecoo.com.cn/dsadasdas/ [imgurl] => http://www.ecoo.com.cn/sadas213/ [price] => 59.9 ) ) 这个是 var_dump 结果array(2) { [0]=> array(7) { ["id"]=> string(1) "1" ["goodstitle"]=> string(54) "琛ユ按娑﹁偆鑶� 鐪熺殑寰堝ソ 寰堣ˉ姘� 鐨偆鏈夊脊鎬�" ["goodsurl"]=> string(70) "http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg" ["brandtitle"]=> string(9) "缇庡疂鑾�" ["brandurl"]=> string(33) "http://www.ecoo.com.cn/dsadasdas/" ["imgurl"]=> string(32) "http://www.ecoo.com.cn/sadas213/" ["price"]=> string(4) "59.9" } [1]=> array(7) { ["id"]=> string(1) "2" ["goodstitle"]=> string(15) "琛ユ按娑﹁偆222" ["goodsurl"]=> string(70) "http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg" ["brandtitle"]=> string(6) "缇�222" ["brandurl"]=> string(33) "http://www.ecoo.com.cn/dsadasdas/" ["imgurl"]=> string(32) "http://www.ecoo.com.cn/sadas213/" ["price"]=> string(4) "59.9" } } 我把 $a 换成 $a = array ( array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ), array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) ); 也是正确的 前台可以接到值 result不是空 是不是数据库的问题 您说的 在读数据的时候也可以转 怎么转UTF-8? 我找了好久我的表是GBK的表 我新建了一个UTF-8的表也不行 $a 在函数中,你调用了吗。函数的return 也不对吧? 谢谢 大神们的支持 由于小弟疏忽 在AJAX请求时 路径写错 其他啥问题都没有 结贴!!! function gtou($s) { return iconv('gbk', 'utf-8', $s); }$a = array ( array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ), array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) );foreach($a as $r) $t[] = array_map('gtou', $r);$moreurl = 'x';$res = array( "status" => "1", "result" => $t, "moreUrl" => $moreurl, ); echo json_encode($res);{"status":"1","result":[{"id":"1102444","title":"\u4e8b\u5b9e\u4e0a","goodstitle":"\u4e8b\u5b9e\u4e0a","price":"429.0","imgurl":".jpg","goodsurl":"\/","brandtitle":"44444","brandurl":"_share\/"},{"id":"1102444","title":"\u8d4c\u4e1c\u9053\u7684","goodstitle":"\u8d4c\u4e1c\u9053\u7684","price":"429.0","imgurl":"0.jpg","goodsurl":"2444\/","brandtitle":"7777","brandurl":"share\/"}],"moreUrl":"x"}不会有问题的,检查你每次的查询条件是否正确!没有查询到,自然就是空数组 求救,PHP这样的批量更新应该怎么做? 给gif动态图片添加水印,在线等!!! wincachegrind 解析xdebug log 出错 PHP函数调用外部变量很怪的一个问题 请教一条MYSQL语句 一个Socket连接发送多个url数据的问题 PHPer学习经验交流群 装完mysql后在c盘没有my.ini PHP中怎么样调试比较方便啊. 我写的一个listdirtree类,请给点建议 求助!!php json 字符串问题 敏感词汇过滤
array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ),
array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) );
也是正确的 前台可以接到值 result不是空 是不是数据库的问题 您说的 在读数据的时候也可以转 怎么转UTF-8? 我找了好久
我的表是GBK的表 我新建了一个UTF-8的表也不行
array( "id" => "1102444","title"=>"事实上","goodstitle"=>"事实上","price"=>"429.0","imgurl"=>".jpg","goodsurl"=>"/","brandtitle"=>"44444","brandurl"=>"_share/" ),
array( "id" => "1102444","title"=>"赌东道的","goodstitle"=>"赌东道的","price"=>"429.0","imgurl"=>"0.jpg","goodsurl"=>"2444/","brandtitle"=>"7777","brandurl"=>"share/" ) );foreach($a as $r) $t[] = array_map('gtou', $r);
$moreurl = 'x';
$res = array(
"status" => "1",
"result" => $t,
"moreUrl" => $moreurl, );
echo json_encode($res);
{"status":"1","result":[{"id":"1102444","title":"\u4e8b\u5b9e\u4e0a","goodstitle":"\u4e8b\u5b9e\u4e0a","price":"429.0","imgurl":".jpg","goodsurl":"\/","brandtitle":"44444","brandurl":"_share\/"},{"id":"1102444","title":"\u8d4c\u4e1c\u9053\u7684","goodstitle":"\u8d4c\u4e1c\u9053\u7684","price":"429.0","imgurl":"0.jpg","goodsurl":"2444\/","brandtitle":"7777","brandurl":"share\/"}],"moreUrl":"x"}不会有问题的,检查你每次的查询条件是否正确!
没有查询到,自然就是空数组