Javascript-jquery Ajax () has several newline characters, solving

Source: Internet
Author: User
Keywords Php javascript jquery firebug html

Using $.ajax () Back-end PHP to get the string, there is only loginsuccess or loginfaild to return a few characters, using alert () and Console.log () to see there is nothing wrong, but with Firebug debugging see, The return value character is appended with a few rnrn characters, which causes the JS judgment to fail.

To search the Internet, but also someone encountered a similar situation, I tried the jquery1.8 and 1.3 of the library, will be more out of these newline characters, do not know this is a jquery bug, or what reason?

Http://www.cnblogs.com/js-html/p/3384940.html

Reply content:

Using $.ajax () Back-end PHP to get the string, there is only loginsuccess or loginfaild to return a few characters, using alert () and Console.log () to see there is nothing wrong, but with Firebug debugging see, The return value character is appended with a few rnrn characters, which causes the JS judgment to fail.

To search the Internet, but also someone encountered a similar situation, I tried the jquery1.8 and 1.3 of the library, will be more out of these newline characters, do not know this is a jquery bug, or what reason?

Http://www.cnblogs.com/js-html/p/3384940.html

Check for extra white space characters outside of PHP tags

Http://stackoverflow.com/questions/11593326/unwanted-new-line-returned-after-ajax-request

If you receive from the server to have such a character, which should be the service side is not good character processing, to see if the corresponding PHP processing is not a lot of characters

The service side returned the wrong data, guess is because the ?> end of the line to knock a few carriage returns to make the PHP code and HTML empty a few lines look good, but after the output of the JSON string after the end of the output of PHP HTML wrapping, it is recommended that if the pure PHP code should not write the Terminator!

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