About Json_encode () puzzles

Source: Internet
Author: User
That's what I wrote in the controller.

Then I output the JSON format in a text like this;

But the receiving end of the old hint system error, Baidu said is the wrong code, but I receive the beginning of the end has been written

And the UFT-8 encoding is also specified in the transmit-side controller.
Now the receiver is unable to accept the data is said to be a system error.

I use Window.alert ("OK"), can succeed
Proof that the data returned, but the error is at Var t here the old hint system error.
How can i solve it?
Can you provide the following code?


Reply to discussion (solution)

Header ("Content-type:application/json")
Give it a try

Header ("Content-type:application/json")
Give it a try


Oh, No. On the Receive page add this sentence to return the entire page to me. The key is that the data is still not getting

The prompt system error is error: System error:-1072896658.
What the hell is that?

If you want to return the JSON data, you must return the ' standard ' JSON data, the standard here is not only for your JSON data is standard, but in your return value can not contain other illegal items!
It is possible that you have other output before or after returning the JSON data, such as the file BOM header, which I encountered a few days ago, my PHP file encoded into UTF-8 but ported to Linux under the beginning of a file a more this character

-
   
Is that small-let me struggle for a long time, and finally the file in front of-all delete it!
It's also possible that your other parts of the code have output such as a space or something else!

4 Floor, I don't understand. I looked at the JSON data I wanted to output, and it's not a problem, but it's my side. No value received
var t = Myxml.responsetext;
This is an old mistake, which means you can't accept it.

Ajax system error:-1072896658

This error occurs when calling the ResponseText method if the document requested by the XMLHttpRequest object does not specify the correct UTF-8 encoding
Browser Systems Error: -1072896658 (Explorer System:-1072896658)

Try a different browser.

Although you added Charset=utf8 to the code,
But what is the actual encoding of your PHP file?

Then I output in a text JSON format is no problem, Chinese use UTF8 encoding. Add code similar to the following in the front-end JavaScript code:

data = eval (' (' + data + ') '); Suppose the received content is saved in data.

If you can't, you put all the papers involved
*.php Plus Header ("Content-type:text/html;charset=utf-8");
Include HTML files, embed JavaScript in place plus charset= "Utf-8"

Is your page code UTF8?

Put your Ajax object in the myXML code and check it out.

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