如何调试AJAX请求?如何知道调用哪个PHP函数?

时间:2022-08-02 14:28:50

I'm debugging Ajax calls.

我正在调试Ajax调用。

How do I know which specific PHP function is called by an ajax call ?

我怎么知道ajax调用调用哪个特定的PHP函数?

I can only see the request and the javascript code triggering the request, but I dunno how is handled on the request on server side ?

我只能看到请求和javascript代码触发请求,但我不知道如何处理服务器端的请求?

I'm currently inspecting all php code, but I was wondering if there is an easier way..

我正在检查所有的PHP代码,但我想知道是否有更简单的方法..

thanks

6 个解决方案

#1


1  

Debugging PHP AJAX Applications with FirePHP

使用FirePHP调试PHP AJAX应用程序

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/serverside-php.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/serverside-php.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-output.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-output.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-object.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-object.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-trace.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-trace.png

#2


3  

An Ajax call does not call a specific function, it merely executes a script. Look at the script, search for its "main" (Whatever name it has in your script) and you'll have the exectued function.

Ajax调用不会调用特定函数,它只执行脚本。查看脚本,搜索它的“main”(它在脚本中有什么名称),你将拥有exectued功能。

#3


1  

If you want a real debug environment and be able to set breakpoints in your php-code, refer to the zend debugger or xdebug. Both can be controlled with the pdt eclipse-plugin or other IDEs.

如果您想要一个真正的调试环境并且能够在php代码中设置断点,请参阅zend调试器或xdebug。两者都可以使用pdt eclipse-plugin或其他IDE进行控制。

If you just want to see some small pieces of information, you can of course just add some echo's or var_dump's to your php-code and then use the firebug firefox extension to view the response to your ajax-requests, which contains the echoed strings.

如果你只是想看一些小信息,你当然可以在你的php代码中添加一些echo或var_dump,然后使用firebug firefox扩展来查看对你的ajax-requests的响应,其中包含了回显的字符串。

#4


0  

I would recommend you make use of FireBug and FirePHP. FirePHP allows you to log from PHP to FireBug console. In this way you can log anything for example all the queries being run or log from methods/functions.

我建议你使用FireBug和FirePHP。 FirePHP允许您从PHP登录到FireBug控制台。通过这种方式,您可以记录任何内容,例如正在运行的所有查询或从方法/函数中记录。

#5


0  

Just use firebug and after the request is sent, look for the response. e.g. function1 echo foo, function2 echo bar, if it's blank...none of those 2 function was called.

只需使用firebug,在发送请求后,查找响应。例如function1 echo foo,function2 echo bar,如果它是空白的......那两个函数都没有被调用。

On my end, I'm using Safari and finding both request / response from an ajax call to a PHP script is a breeze.

在我的结尾,我正在使用Safari并从ajax调用PHP脚本中查找请求/响应是轻而易举的。

#6


0  

Debugging using Firefox's addon FireBug, you can check out the request and response data content easily.

使用Firefox的插件FireBug进行调试,您可以轻松查看请求和响应数据内容。

http://www.daniweb.com/web-development/php/code/216729

So by right, Ajax cannot access remote web server content, so you need the proxy page in the middle of the whole architecture flow.

所以,通过权利,Ajax无法访问远程Web服务器内容,因此您需要在整个架构流程中间的代理页面。

So which means: [Within Same Server] PHP page using AJAX -> Web Services / Web Server that contains your response functions

这意味着:[在Same Server中]使用AJAX的PHP页面 - >包含您的响应函数的Web服务/ Web服务器

[Within 2 Servers, Connecting to Remote Server] PHP page using AJAX -> PHP Proxy Page -> Web Services / Web Server that contains your response functions

[在2台服务器中,连接到远程服务器]使用AJAX的PHP页面 - > PHP代理页面 - >包含响应功能的Web服务/ Web服务器

So the overall proxy page acting like a "middle-man" to connect to remote site.

所以整个代理页面就像一个“中间人”连接到远程站点。

[IMPORTANT] Don't confuse router proxy and proxy page, but have the same theory but it is different thing.

[重要]不要混淆路由器代理和代理页面,但有相同的理论,但它是不同的东西。

#1


1  

Debugging PHP AJAX Applications with FirePHP

使用FirePHP调试PHP AJAX应用程序

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/serverside-php.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/serverside-php.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-output.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-output.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-object.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-object.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-trace.png

alt text http://www.diloc.de/blog/wp-content/uploads/2008/07/firebug-trace.png

#2


3  

An Ajax call does not call a specific function, it merely executes a script. Look at the script, search for its "main" (Whatever name it has in your script) and you'll have the exectued function.

Ajax调用不会调用特定函数,它只执行脚本。查看脚本,搜索它的“main”(它在脚本中有什么名称),你将拥有exectued功能。

#3


1  

If you want a real debug environment and be able to set breakpoints in your php-code, refer to the zend debugger or xdebug. Both can be controlled with the pdt eclipse-plugin or other IDEs.

如果您想要一个真正的调试环境并且能够在php代码中设置断点,请参阅zend调试器或xdebug。两者都可以使用pdt eclipse-plugin或其他IDE进行控制。

If you just want to see some small pieces of information, you can of course just add some echo's or var_dump's to your php-code and then use the firebug firefox extension to view the response to your ajax-requests, which contains the echoed strings.

如果你只是想看一些小信息,你当然可以在你的php代码中添加一些echo或var_dump,然后使用firebug firefox扩展来查看对你的ajax-requests的响应,其中包含了回显的字符串。

#4


0  

I would recommend you make use of FireBug and FirePHP. FirePHP allows you to log from PHP to FireBug console. In this way you can log anything for example all the queries being run or log from methods/functions.

我建议你使用FireBug和FirePHP。 FirePHP允许您从PHP登录到FireBug控制台。通过这种方式,您可以记录任何内容,例如正在运行的所有查询或从方法/函数中记录。

#5


0  

Just use firebug and after the request is sent, look for the response. e.g. function1 echo foo, function2 echo bar, if it's blank...none of those 2 function was called.

只需使用firebug,在发送请求后,查找响应。例如function1 echo foo,function2 echo bar,如果它是空白的......那两个函数都没有被调用。

On my end, I'm using Safari and finding both request / response from an ajax call to a PHP script is a breeze.

在我的结尾,我正在使用Safari并从ajax调用PHP脚本中查找请求/响应是轻而易举的。

#6


0  

Debugging using Firefox's addon FireBug, you can check out the request and response data content easily.

使用Firefox的插件FireBug进行调试,您可以轻松查看请求和响应数据内容。

http://www.daniweb.com/web-development/php/code/216729

So by right, Ajax cannot access remote web server content, so you need the proxy page in the middle of the whole architecture flow.

所以,通过权利,Ajax无法访问远程Web服务器内容,因此您需要在整个架构流程中间的代理页面。

So which means: [Within Same Server] PHP page using AJAX -> Web Services / Web Server that contains your response functions

这意味着:[在Same Server中]使用AJAX的PHP页面 - >包含您的响应函数的Web服务/ Web服务器

[Within 2 Servers, Connecting to Remote Server] PHP page using AJAX -> PHP Proxy Page -> Web Services / Web Server that contains your response functions

[在2台服务器中,连接到远程服务器]使用AJAX的PHP页面 - > PHP代理页面 - >包含响应功能的Web服务/ Web服务器

So the overall proxy page acting like a "middle-man" to connect to remote site.

所以整个代理页面就像一个“中间人”连接到远程站点。

[IMPORTANT] Don't confuse router proxy and proxy page, but have the same theory but it is different thing.

[重要]不要混淆路由器代理和代理页面,但有相同的理论,但它是不同的东西。