How to debug a php script with ajax request?

The bottom line is this: on the client side is a form sending via ajax the generated object
ajaxSent function(obj) {
 let body = JSON.stringify(obj);
 body = 'incedentInfo=' + encodeURIComponent(body); 

 let xhr = new XMLHttpRequest();
 xhr.open("POST", "./php/insertToDB.php", true);
 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(body);
}

There is a script that the object takes.
Tell me how to debug script? (I need to see what mistakes and notiсe it will be released with the current data) because, unlike normal not ajax form redirects to a php script. Tried to output information from php into a text document, but as for me it is a perversion.
How do you do that?
March 25th 20 at 13:42
4 answers
March 25th 20 at 13:44
Solution
1) Is for debugging, of course, is Xdebug. Install, configure in your ide and naslazhdatsya all the pleasures of breakpoints, etc.
2) the Other option is to logowanie. Don't understand why such hostility to the logs. It's not "foo files" is a mandatory attribute more or less large project. At least during the investigation of incidents logs can help you a lot. Just implement monolog or any other implementation of psr\logger.
3) If the options above do you still think "surecom" even after my words. Well, try watching in standard log php-fpm(php-cli), may be enough. Or try using strace.
4) If all of the above kanaet... Well, you can simulate a post request using postman, for example. You can display the query result in the browser console. But it is definitely distorted.
once they say loggi not evil, who am I to argue) Look to Xdebug. Thanks for the detailed answer - mauricio.Powlowski commented on March 25th 20 at 13:47
March 25th 20 at 13:46
There is a script that the object takes.
unlike normal ajax form not redirects to a php script.

Logic is logic.

Developer tools, Network tab, zamkem to your query - surprise! - PHP script. Check the output
Maybe I did not understand you. I know about the network tab, but there we see only what goes into the script, (it matters not), and I need something that meets the php and debugging a php script. - mauricio.Powlowski commented on March 25th 20 at 13:49
@mauricio.Powlowski, there is an answer, tab preview and response. For example, I have a returned json
5d4a4f7f5ea51952091106.png - Gage.Pouros97 commented on March 25th 20 at 13:52
Damn, I knew that something just do not know) thank you - mauricio.Powlowski commented on March 25th 20 at 13:55
March 25th 20 at 13:48
wouldn't it be easier to disable ajax, everything to debug and then enable ajax?
there will have to dance with a tambourine substituting a standard form submission on the generated object - mauricio.Powlowski commented on March 25th 20 at 13:51
March 25th 20 at 13:50
on Firefox CTRL+SHIFT+E

Find more questions by tags HTMLPHPAJAX