javascript - What's the best way to debug AJAX to PHP calls? -


I'm having a sad time debugging a small function on my new project

Originally I Logging out a user by logging out "userffunctions.php" on the logout script on my server via an AJAX call, I am using AJAX so that I do not have the headache to write to match your mod_rewrites For more regex anyway, every time it seems that my post data just flattens and Since PHP is running behind the scenario, I think I have no way to figure out why the data flow is interrupted. BTWIDE This function works at 19 o'clock.

Here is the JavaScript function:

  function logout () {var data = new object; Data.log_out = true; $ .ajax ({type: 'post', url: 'http://www.mydomain.com/user_validator', // "redirection functions.php for user data: data, success: function (data) {Warning (data); // <- A response has started, but there is no feedback data!}}); }  

php side:

  if (isset ($ _ POST ['log_out'])) {echo 'this warning!'; }  

Here is my awesome response:

:

FirePHP enables you to log in to your FireBug console using a simple PHP method call.

All data is sent through feedback headings and does not interfere with the content on your page.

FirePHP is ideally suited for AJAX development where clean JSON and XML reactions are required.

There is a minimum implementation that I wrote:

  function firefah ($ message, $ label = empty, $ type = 'log') { Stable $ i = 0; If (headers_sent () === incorrect) {$ type = (in_array ($ type, array ('LOG', 'INFO', 'WARN', 'ERROR')) === incorrect)? 'LOG': $ type; If ($ _SERVER ['HTTP_HOST'] == 'localhost') & amp; (strops ($ _ server ['HTTP_USER_AGENT'], 'FirePHP'! == incorrect)) {$ message = json_encode (array ('Type' = & gt; $ type, 'label' = & gt; $ label), $ message)); If ($ i == 0) {Header ('X-WF-Protocol-1: http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); Header ('x-wf-1-plugin-1: http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3'); Header ('x-wif-1-structure-1: http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); } Header ('X-Wf-1-1-1-'. ++ $ i. ':'. Strlen ($ message) ''. '$ Message.' | '); }}}  

I wrote that this only works on localhost (for security reasons), but you can easily change by changing that code:

< Pre> if (($ _SERVER ['HTTP_HOST'] == 'localhost') & amp; amp; (Stops ($ _ server ['HTTP_USER_AGENT'], 'FirePHP')! == incorrect)

/ html>

Comments