Die (Json_encode (. No return

Source: Internet
Author: User
My Ajax Code
$.post (' {: U ("Safeinfo/txpassadd")} ', $ ("#txadd"). Serialize (), function (data) {alert ("OK"), ....


PHP Code:
Tip ("100", "Transaction password cannot be the same as login 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 result page does not pop up the alert ("OK"), indicating that Ajax did not return?

It's not possible to change this:
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}


What is this for?


Reply to discussion (solution)

This is not possible: (

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?



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

It should be something else.
You check the source file in the browser

Output UTF-8-encoded
{"Code": "+", "MSG": "The transaction password cannot be the same as the login password!" "}
It should be something else.
You check the source file in the browser



Page source code:
...                   
 
  
  
  • Transaction password
  • In order to secure your account, you need to enter the transaction password, please make sure it is different from the login password.
  • Set cancellation settings
  • Retrieve password Cancel Retrieve
...


The current page shows the contents of safeinfo-jiaoyimima.html,
The contents of safeinfo-jiaoyimima.html are as follows:

 
  Untitled Document
 
  
 
            


How to change the code is only pop-up alert ("Ok1"); No popup alert ("Ok2"); Depressed for a few days! Please advise, thank you!

What I want you to see is:
$.post (' {: U ("Safeinfo/txpassadd")} ', $ ("#txadd") in the template. Serialize (), function (data) {
What is in the browser source code?

What I want you to see is:
$.post (' {: U ("Safeinfo/txpassadd")} ', $ ("#txadd") in the template. Serialize (), function (data) {
What is in the browser source code?



I look at the current page source code is the first code upstairs, but I do not know how to view the template in Firefox $.post (' {: U ("Safeinfo/txpassadd")} ', $ ("#txadd"). Serialize (), function (data) {The source code in the browser.

Baffled, confused Ah!

Teachers, so preach, tuition, doubts, who is my teacher?

Why do you omit the code you see in the browser?

$.post (' {: U ("Safeinfo/txpassadd")} ', $ ("#txadd"). Serialize (), function (data) {alert ("OK"), ...}, "JSON");

In jquery, indicate the type of the return parameter

Why do you omit the code you see in the browser?



                
 
  
 <title>Security Settings-Guilin financial Bao Zhong Investment loan Platform</title>
            


This is all the code, thank you!

You do this, right?
Neither saw Id=txadd's mark, had not seen $.post (.... Code

You do this, right?
Neither saw Id=txadd's mark, had not seen $.post (.... Code



These codes are in safeinfo-jiaoyimima.html, and the safeinfo-jiaoyimima.html code is in the 5 downstairs half.
Please note this code in the code above:

Since it's in the frame, you're going to post the HTML code you see in the frame.
#5 just the template file, if it is directly used must not be

Since it's in the frame, you're going to post the HTML code you see in the frame.
#5 just the template file, if it is directly used must not be



The framework code you see is:
 
  Untitled Document    

Dear @xuzuning Teacher, Hello, why not the following?

Click Submit, just pop up alert ("Ok1"); No popup alert ("Ok2"); What the hell is this?

safeinfo-txpassadd.html code?

safeinfo-txpassadd.html code?



Thank you for your reply! Without this file, only SafeinfoAction.class.php:
Class Safeinfoaction extends Baseaction {public Function _initialize () {parent::_initialize ();        $this->time = $_session[' e_time ');        $webData = M (' web ')->where (' id=1 ')->find (); $this->meta = Array (' title ' = ' Security Settings-'. $webData [' Webtitle '], ' keywords ' = ' security Settings | '. $    webdata[' Webkeyword '], ' description ' = Strip_tags ($webData [' new_notice ']);    } Const EXPIRED_TIME = 120;        Displays the Security Information page Public Function index () {import (' @.org.string ');        $user = M ("User_info");        $user 1 = M ("user");        $auth = M (' Auth_info ');        $list = $user->where ("uid=". $_session["UID"])->find ();        $list 1 = $user 1->where ("id=". $_session["UID"])->find ();        $data [' uid '] = $_session[' uid '];        $data [' auth_type '] = 1;        $list 2 = $auth->where ($data)->find ();        $this->as["user"] = $list;        $this->as["user1") = $list 1; $this->as["User2"] = $list 2;        $this->assign ($this->as);    $this->display ();        }//Withdraw password add Public function Txpassadd () {$user = M (' user '); if (I (' txpass ') = = "" | |        I (' rtxpass ') = = "") {tip (' 100 ', ' Please enter full information '); } if (I (' txpass ')! = I (' Rtxpass ')) {Tip ("3", ' two times entered passwords are inconsistent!)        ');        } $map [' id '] = $this->uid;        $u = $user->where ($map)->find (); if (empty ($u)) {Tip ("100", ' Unknown user!        ');        } $data [' u_trade_password '] = I (' Rtxpass ', ' ', ' fix_pass '); if ($data [' u_trade_password '] = = $u [' U_password ']) {tip ("100", ' Transaction password cannot be the same as login password!        ');        } $status = $user->data ($data)->where (' id= ' $_session[' uid ')->save (); if ($status) {Tip ("10000", ' Submit success!        '); } else {tip ("2", ' Setup failed, please try again!        '); }    }

Safeinfo-txpassadd.html is actually executed after the URL rewrite
Safeinfoaction::txpassadd method
It uses the Tip function, and I don't know how you define it.

Your $.post method has a JSON declaration, so the tip function should output a JSON format string
And $.post's callback function parameter data has been parsed into a JS object
You again var data1=eval ("(" +data+ ")"); There is a Huperzia serrata, should be removed

You have to debug your PHP code first.

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));//Die    (Var_json_encode ($arr));  CJQ}

For tip ("100", the ' transaction password cannot be the same as the login password! ');
{"Code": "+", "msg": "\u4ea4\u6613\u5bc6\u7801\u4e0d\u80fd\u4e0e\u767b\u5f55\u5bc6\u7801\u4e00\u6837\uff01< \/font> "}
If written
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}

Then tip ("100", ' Transaction password cannot be the same as login password! ');
{"Code": "+", "MSG": "The transaction password cannot be the same as the login password!" "}
It's a mistake!

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!

It doesn't make any sense, it's a try.

function Tip ($code, $msg) {  $arr [' code '] = UrlEncode ($code);  $arr [' msg '] = UrlEncode ($msg);  $s = Json_encode ($arr);  Die (UrlDecode ($s);}

It doesn't make any sense, it's a try.

function Tip ($code, $msg) {  $arr [' code '] = UrlEncode ($code);  $arr [' msg '] = UrlEncode ($msg);  $s = Json_encode ($arr);  Die (UrlDecode ($s);}



Thank you boss, tried, so that the Ajax can not return,
Click Submit, just pop up alert ("Ok1"); No popup alert ("Ok2");

Alas, this Ajax stuff is really hard to get!

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