欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

!php+ajax+ json 有关问题

程序员文章站 2024-01-14 11:18:40
...
求助!!php+ajax+ json 问题
本帖最后由 zl2727 于 2013-12-10 18:08:23 编辑

function gtou($s) { return iconv('gbk', 'utf-8', $s); }
$proquery ="select * from pro where typeid='".$id."' order by corank asc";
$dsql->SetQuery($proquery);
$dsql->Execute();
$a=array();
while($row = $dsql->GetArray())
{
$a[]= array_map('gtou', $row);
}
$res = array(
"status" => "1",
"result" => $a,
"moreUrl" => $moreurl, );
echo json_encode($res);

现在前台 返回值是{"status":"1","result":[],"moreUrl":"http:\/\/wcn"} result 是空的
如果
echo json_encode($res);
换成下面的
//echo '{"status":"1","result":[{"id":"1","typeid":"111","goodstitle":"\u8865\u6c34\u6da6\u80a4\u818f \u771f\u7684\u5f88\u597d \u5f88\u8865\u6c34 \u76ae\u80a4\u6709\u5f39\u6027","goodsurl":"http:\/\/www.\/uploads\/allimg\/c131205\/13V23912150-114L_lit.jpg","brandtitle":"\u7f8e\u5b9d\u83b2","brandurl":"http:\/\/www.\/dsadasdas\/","imgurl":"http:\/\/www.\/sadas213\/","price":"59.9","corank":"1"},{"id":"2","typeid":"111","goodstitle":"\u8865\u6c34\u6da6\u80a4222","goodsurl":"http:\/\/www.\/uploads\/allimg\/c131205\/13V23912150-114L_lit.jpg","brandtitle":"\u7f8e222","brandurl":"http:\/\/www.\/dsadasdas\/","imgurl":"http:\/\/www.\/sadas213\/","price":"59.9","corank":"1"}],"moreUrl":"http:\/\/jianfei.\/shuiguo\/"}'; 就正确了
请大神们帮个忙 版主也麻烦您再次指导以下

网友评论

文明上网理性发言,请遵守 新闻评论服务协议

我要评论
  • !php+ajax+ json 有关问题
  • 专题推荐

    作者信息
    !php+ajax+ json 有关问题

    认证0级讲师

    推荐视频教程
  • !php+ajax+ json 有关问题javascript初级视频教程
  • !php+ajax+ json 有关问题jquery 基础视频教程
  • 视频教程分类