Continue to ask: die (json_encode (. no response

Source: Internet
Author: User
Continue question: die (json_encode (. no response to continue this post question: http://bbs.csdn.net/topics/390901967
I closed the wrong post and thought it had solved the problem, but it was not actually solved.
So please continue with your guidance! Thank you!

Review of main issues:
Reply from xuzuning on the 24th floor of the old post:
The tip function should be written in this way.
function tip($code, $msg) {    $arr['code'] = iconv('GB2312', 'UTF-8', $code);    $arr['msg'] = iconv('GB2312', 'UTF-8', $msg);         die(json_encode($arr));}


Thank you! In this case, a response is returned, but there is a problem:
$(".tscg4").html(data.msg);  

The value of data. msg in is changed to a bang
How to change back: the transaction password cannot be the same as the login password! What about it?
Thank you for your advice!


Reply to discussion (solution)

Alert (data. msg );
Screenshot

Wait a moment, is on the Internet can not find the appropriate, really easy to use conversion UTF-8 encoding to GB2312 function.
However, my page head contains tags.
It shouldn't be garbled!

Alert (data. msg );
Screenshot



What you pass to the tip function is a string constant, so your program file is not UTF-8?
What is your browser? What is the php version? I cannot reproduce your phenomenon at all.
In short, 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));}

Is the main program file and utf8?
In addition ?
If not, change it to utf8 before testing.

What you pass to the tip function is a string constant, so your program file is not UTF-8?
What is your browser? What is the php version? I cannot reproduce your phenomenon at all.
In short, 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 your reply. the tip function is written in this way, and ajax cannot return to the original page,
I said in this post on the second floor, is on the Internet can not find the appropriate, really useful conversion UTF-8 encoding to GB2312 function.
However, my page head contains tags.
It shouldn't be garbled!
The program file is not utf-8. what does it mean? Is it a php file? SafeinfoAction. class. php or functions. php (which contains the tip function )?
I open these two files and save them as Unicode standardized form: C (canonical decomposition followed by canonical synthesis)

If your program file is UTF-8, 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.