! Php + ajax + json

Source: Internet
Author: User
Help !! Php + ajax + json at the end of this post, the function & nbsp; gtou ($ s) & nbsp ;{& nbsp; return & nbsp; was edited by zl2727 from 2013 to 12-10:08:23; iconv ('gbk' for help !! Php + ajax + json
This post was last edited by zl2727 at 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);
 

The returned value is {"status": "1", "result": [], "moreUrl": "http: \/wcn"}. The result is null.
If
Echo json_encode ($ res );
Change to the following
// Echo '{"status": "1", "result": [{"id": "1", "typeid": "111", "goodstitle ": "\ u8865 \ u6c34 \ u6da6 \ u80a4 \ u818f \ Alibaba \ u7684 \ Alibaba \ u597d \ Alibaba \ u8865 \ Alibaba \ 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 \/"} '; that's correct. Please help the moderators and instruct them to share the following: More

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.