Die (json_encode (. no return

Source: Internet
Author: User
Tags account security
Die (json_encode (. didn't return my ajax code
$.post('{:U("Safeinfo/txpassadd")}', $("#txadd").serialize(), function(data) { alert("ok");...


Php code:
Tip ("100", 'transaction password cannot be the same as logon password! ');


function tip($code, $msg) {    $arr['code'] = iconv('GB2312', 'UTF-8', $code);    $arr['msg'] = iconv('GB2312', 'UTF-8', $msg);    //die(json_encode($arr));    die(var_json_encode($arr));  //cjq}function var_json_encode($var){  $_var = var_urlencode($var);  $_str = json_encode($_var);  return urldecode($_str); }


The alert ("OK") is not displayed on the result page. why is ajax not returned?

This cannot be done either:
function tip($code, $msg) {    $arr['code'] = iconv('GB2312', 'UTF-8', $code);    $arr['msg'] = iconv('GB2312', 'UTF-8', $msg);    die(json_encode($arr,JSON_UNESCAPED_UNICODE));  //cjq}


Why?


Reply to discussion (solution)

This is not the case :(

function tip($code, $msg) {    $arr['code'] = $code;    $arr['msg'] = $msg;    die(json_encode($arr,JSON_UNESCAPED_UNICODE));  //cjq}

$ _ Var = var_urlencode ($ var );
Where is this function defined?

$ _ Var = var_urlencode ($ var );
Where is this function defined?



/*** Encode the variable or data using urlencode, so that the encoding for json_encode is not Chinese, prevention of json_encode failure * @ access private * @ param $ var * @ return array */function var_urlencode ($ var) {if (empty ($ var) {return false ;} if (is_array ($ var) {foreach ($ var as $ k => $ v) {if (is_scalar ($ v )) {// if is used to handle situations where the array is not $ var [$ k] = urlencode ($ v );} else {// else is used to process arrays $ var [$ k] = var_urlencode ($ v );}}} else {// used to process arrays $ var = urlencode ($ var);} return $ var ;}

UTF-8 encoded
{"Code": "100", "msg": "The transaction password cannot be the same as the login password! "}

It should be other issues
Check the source file in the browser.

UTF-8 encoded
{"Code": "100", "msg": "The transaction password cannot be the same as the login password! "}
It should be other issues
Check the source file in the browser.



Page Source code:
...

  • Transaction password
  • For your account security, you need to enter the transaction password for withdrawal. make sure the password is different from the logon password.
  • Set cancel settings

  •  
  •  
  • Cancel password retrieval

...


The preceding page displays the content of safeinfo-jiaoyimima.html,
The safeinfo-jiaoyimima.html content is as follows:

 Untitled Document
 
 

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.