Continue to ask: Die (Json_encode (. No return

Source: Internet
Author: User
Tags sprintf
Continue with this post's question: http://bbs.csdn.net/topics/390901967
I had the wrong post and thought that I had solved the problem.
So please continue to guide the Master Guide it! Thank you very much!

Review of major issues:
Old Post 24 floor xuzuning's reply:
The Tip function should be written like this
function Tip ($code, $msg) {    $arr [' code '] = Iconv (' GB2312 ', ' UTF-8 ', $code);    $arr [' msg '] = iconv (' GB2312 ', ' UTF-8 ', $msg);         Die (Json_encode ($arr));}


Thank you! It did return, but there was a problem:
$ (". Tscg4"). HTML (DATA.MSG);  

The value of data.msg into Bang Yukata
How to change back: The transaction password cannot be the same as the login password! It?
Please continue to advise, thank you very much!


Reply to discussion (solution)

alert (data.msg);
Cut a picture

Wait a moment, is on the net can not find the suitable, really good conversion UTF-8 encoding to GB2312 function.
But my page has a tag in the head.
Should not be garbled ah!

alert (data.msg);
Cut a picture



You pass a string constant to the tip function, so your program file is not utf-8?
What is your browser? What is the PHP version? I can't reproduce your phenomenon here.
Anyway, we need to see the tip output.

Your tip function can also be written.

function Tip ($code, $msg) {  $s = sprintf (' {"Code": "%s", "MSG": "%s"} ', $code, $msg);  Die (Iconv (' GBK ', ' utf-8 ', $s));}

Landlord's program files and is not UTF8?
Are there any additional pages ?
If not, first change to UTF8 test again.

You pass a string constant to the tip function, so your program file is not utf-8?
What is your browser? What is the PHP version? I can't reproduce your phenomenon here.
Anyway, we need to see the tip output.

Your tip function can also be written.

function Tip ($code, $msg) {  $s = sprintf (' {"Code": "%s", "MSG": "%s"} ', $code, $msg);  Die (Iconv (' GBK ', ' utf-8 ', $s));}



Thanks for the reply, the Tip function is written so that Ajax can not return to the original page,
I said on the 2 floor of this post, is not found on the internet suitable, really useful conversion UTF-8 encoding to GB2312 function.
But my page has a tag in the head.
Should not be garbled ah!
The program file is not utf-8, what does it mean? Refers to PHP files? SafeinfoAction.class.php or functions.php (inside the tip function)?
I open these two files, save as on the page there: Unicode normalization form: C (canonical decomposition, followed by canonical synthesis)

If your program file is Utf-8, then why $arr [' msg '] = iconv (' GB2312 ', ' UTF-8 ', $msg);?

  • 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.