如何使用PhpStorm和Xdebug调试AJAX(POST)? [英] How to debug AJAX (POST) with PhpStorm and Xdebug?

查看:82
本文介绍了如何使用PhpStorm和Xdebug调试AJAX(POST)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将PhpStorm配置为调试HTTP GET-但仅当我直接加载页面时.

I have configured PhpStorm to debug HTTP GET - but only when I load a page directly.

当我想调试AJAX时,我使用JS请求的URL并创建一个PhpStorm配置来对其进行调试.

When I want to debug AJAX, I take the URL which my JS would request and create a PhpStorm configuration to debug it.

不是特别优雅吗?

当然,对于POST请求,我不能这样做(或者可以吗?).

And, of course, I can't do that for POST requests (or can I?).

理想情况下,我想在浏览器(Chrome)中加载AngularJs应用,并能够在PhpStorm中断点并调试后端.

Ideally, I would like to load my AngularJs app in the browser (Chrome) and be able to breakpoint and debug the backend in PhpStorm.

我在Google上搜索了很多,发现有很多接近,但我找不到答案:-(

I googled a lot, and found much that came close, but I can't find the answer :-(

谁可以提供帮助?

[更新]几年后,我正在使用出色且免费的邮递员来测试这两个GET和POST.

[Update] a few years later, and I am using the excellent and free Postman to test both GET and POST.

推荐答案

如果将Xdebug和PHPStorm配置为在正常加载页面时调试HTTP GET,则只需在Javascript的AJAX请求的URL中包含GET参数.例如: http://example.com/script.php?XDEBUG_SESSION_START=PHPSTORM

If Xdebug and PHPStorm are configured to debug HTTP GET when loading a page normally, then simply include the GET parameter in the URL of the AJAX request in your Javascript. For example: http://example.com/script.php?XDEBUG_SESSION_START=PHPSTORM

在PHPStorm中打开侦听",发送带有新URL的AJAX请求,调试器应捕获该请求.您要查找的POST数据应照常显示在$ _POST中.

Turn on Debug listening in PHPStorm, send the AJAX request with the new URL, and the debugger should catch it. The POST data you are looking for should appear in $_POST as usual.

这篇关于如何使用PhpStorm和Xdebug调试AJAX(POST)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆