Help!! php+ajax+ JSON issues

Source: Internet
Author: User
This post was last edited by zl2727 on 2013-12-10 18:08:23


The foreground return value is now {"Status": "1", "result": [], "Moreurl": "HTTP:\/\/WCN"} result is empty
If
echo Json_encode ($res);
Replace the following
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\/"} '; Please ask the gods to do a favor. Moderator also trouble you to guide the following


Reply to discussion (solution)

Output with Var_dump

Print_r ($a); Look

Array ([0] = = Array ([id] = 1 [goodstitle] ~ = Arrival by the suo??????? Atlas ソ ˉt Matthews?????? Ridge?? [Goodsurl] = http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg [Brandtitle] + twips???? [Brandurl] = http://www.ecoo.com.cn/dsadasdas/[Imgurl] = http://www.ecoo.com.cn/sadas213/[price] + 59.9) [1] = = Array ([id] = 2 [Goodstitle] = arrival by the suo?? 222 [Goodsurl] [http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg] [brandtitle] = twips 222 [Brandurl] = http://www.ecoo.com.cn/dsadasdas/[Imgurl] = http://www.ecoo.com.cn/sadas213/[price] + 59.9) )

This is var_dump result.

Array (2) {[0]=> Array (7) {["id"]=> string (1) "1" ["Goodstitle"]=> string (54) "Aachen arrival by Suo??????? Atlas ソ ˉt Matthews?????? Ridge?? " ["Goodsurl"]=> string "http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg" [" Brandtitle "]=> string (9)" twips???? " ["Brandurl"]=> string "http://www.ecoo.com.cn/dsadasdas/" ["Imgurl"]=> string (+) "http://www.ecoo.com.cn /sadas213/"[" Price "]=> string (4)" 59.9 "} [1]=> Array (7) {[" id "]=> string (1)" 2 "[" Goodstitle "]=> string (15) "Arrival by the suo?" 222 "[" Goodsurl "]=> string ()" Http://www.ecoo.com.cn/uploads/allimg/c131205/13V23912150-114L_lit.jpg "[" Brandtitle "]=> string (6)" Twips 222 "[" Brandurl "]=> string" http://www.ecoo.com.cn/dsadasdas/"[" Imgurl "]=> String (+) "http://www.ecoo.com.cn/sadas213/" ["Price"]=> string (4) "59.9"}}

No, $a is not empty, it will not output an empty array

Can you add me to the moderator? I send you a test to connect you to see

I'll change $a.

$a = array ("id" = "1102444", "title" = "de facto", "Goodstitle" and "de facto", "price" = "429.0", "imgurl" and "=". JPG "," goodsurl "="/"," brandtitle "=" 44444 "," Brandurl "and" _share/"), Array (" id "=" 1102444 "," title "= > "Dongdao", "Goodstitle" and "Dongdao", "price" = "429.0", "imgurl" = "0.jpg", "Goodsurl" and "2444/", "Brandtitle "= =" 7777 "," brandurl "=" share/");
Also the correct foreground can receive the value result is not empty

is not the database of the problem you say in reading the data can also turn how to turn UTF-8? I've been looking for a long time
My watch is GBK's watch, and I'm not going to create a UTF-8 table.

$a in the function, did you call it. The return of the function is also wrong, right?

Thanks to the great gods for their support.

Path write error on Ajax request

There's nothing else.

Knot stickers!!!

function Gtou ($s) {return iconv (' GBK ', ' utf-8 ', $s);} $a = array ("id" = "1102444", "title" = "de facto", "Goodstitle" and "de facto", "price" = "429.0", "imgurl" and "=". JPG "," goodsurl "="/"," brandtitle "=" 44444 "," Brandurl "and" _share/"), Array (" id "=" 1102444 "," title "= > "Dongdao", "Goodstitle" and "Dongdao", "price" = "429.0", "imgurl" = "0.jpg", "Goodsurl" and "2444/", "Brandtitle "= =" 7777 "," brandurl "=" share/"), foreach ($a as $r) $t [] = Array_map (' Gtou ', $r); $moreurl = ' x '; $res = Array (" Stat US "+" 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"}

There will be no problem, check your query every time the condition is correct!
No query, nature is an empty array
  • 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.