Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Ajax/PHP debugging

I'm testing an Ajax/jQuery-loaded PHP module and I was wondering if there's a simple way to debug this without using a full featured debugger.

My very simple debugging option is to echo some data and read browser output, however due to Ajax-loaded modules nature, output is hidden.

While I can return debugging data until the ajax-loaded module is running, I can't track or "see" program interruptions if error occurs.

Is there a way to allow "output" also in the ajax-loaded modules? Or ?

like image 843
Riccardo Avatar asked Mar 30 '11 10:03

Riccardo


4 Answers

I suppose a solution could be using FirePHP :

  • On the PHP side, you generate some specific HTTP-headers -- which will not be part of the output itself -- using its PHP library.
  • And, in Firefox, you install the FirePHP extension, which will parse those headers, and display the corresponding data in Firebug.
like image 72
Pascal MARTIN Avatar answered Nov 09 '22 05:11

Pascal MARTIN


Use WebKit's console (Chrome / Safari) or FireBug to check what's going on and make use of console.log() in both. Google a bit to see what console is and how console.log() is useful for debugging in such apps. In webkit you can also have breakpoints and other nice fiddly things that usually only IDE's offer.

like image 38
Michael J.V. Avatar answered Nov 09 '22 05:11

Michael J.V.


Grab the 'HTTPFox' add on for Firefox, you'll wonder how you managed to do anything (especially with AJAX) without it.

https://addons.mozilla.org/en-US/firefox/addon/httpfox/

like image 1
Codecraft Avatar answered Nov 09 '22 05:11

Codecraft


It is also possible to inspect requests and responses on a browser agnostic basis with Fiddler so debugging Ajax can be done on any browser, even old versions of Internet Explorer.

like image 1
alfmartinez Avatar answered Nov 09 '22 04:11

alfmartinez