Problems related to debugging php code when ajax calls php

Source: Internet
Author: User
When ajax calls php, the problem of debugging php code is a newbie. when I debug a program, when ajax calls php, code in php needs to be debugged, but in this case, the methods for writing logs, echo, print, and other information output in php code are invalid. & nbsp; do you know why? is there any way to debug the php code? Thank you ------ solution ------------------ you have the problem of debugging the php code when installing fire ajax to call php?
A newbie
I encountered a problem when debugging the program.
When ajax calls php, you need to debug the code in php.
However, in this case, the methods for writing logs, echo, print, and other information in php code are invalid.
Do you know why?

Is there any way to Debug php code?
Thank you.

------ Solution --------------------
Have you installed firebug? Echo debugging is fine.

If an exception alert (msg) exists in try catch after ajax is returned.
------ Solution --------------------
Put_file_contents ('C: \ error.txt ', $ string); // save it to an external file. $ string indicates the variable you suspect is faulty.
This code may not be placed at the end of the page. If it cannot be saved as a file, it indicates that there is a problem with your previous code. move this sentence a few lines up. if it can be saved, your $ string is the value you want, skip this variable and move the code down.
Stupid way to exchange experiences.
------ Solution --------------------
Debugging ajax + php without tools is quite difficult.
It needs to be debugged in stages. the js part is relatively simple and there will be no problems after planning.
Debugging in php is no different from debugging on common pages, as long as there is no error message or data format that complies with the conventions.
Ajax is nothing more than getting data through get and post requests. You can design a form to replace xmlhttp sending. because the page is visible, it is easy to find problems.

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.