Why is a strange value transmitted from php to JS? Solution

Source: Internet
Author: User
Why is a strange value transmitted from php to JS? I want to transfer 0 from a. php to B. js, but there is a huge string! The original code is as follows: a. php file: & lt ;? Phpecho & quot; 0 & quot ;;? & Gt; B. js file: functionget_C () {& nbsp; if (xmlHttp. readyState4 | xmlHttp. readyState is passed to JS from php, but a strange value is returned?
I want to transfer 0 from a. php to B. js, but there is a huge string! The original code is as follows:


A. php file:

Echo "0 ";

?>


B. js file:

Function get_C ()
{
If (xmlHttp. readyState = 4 | xmlHttp. readyState = "complete ")
{
Var c = xmlHttp. responseText;
Alert (c );
}
}

The result of the dialog box is as follows:




Untitled Document





0

What's going on? Can I remove a lot of the above?




------ Solution --------------------
A outputs json
B. read json alert
------ Solution --------------------
Where did the preceding html come from? Run a. php and check the source code. Check whether there is any html code.

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.