NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to debug server-side php that responds to XMLHttpRequest


Joined: 09 Jul 2007
Posts: 4
Reply with quote
I am writing a relatively simple AJAX-style page in Javascript, which sends some information to a php program on the server that does some calculations and sends a response. The main javascript is in the main html file, and the php is in a single php file. main.html <-XMLHttpRequest-> calc.php

I have phped up and running, and can step through other php-style pages if they are the main page, but have not been able to debug this AJAX php. I am set up with a local server on my development computer.

If I start the debugger with the html page, it just runs in the browser, runs the php, but does not stop at any breakpoints I have set.

If I start the debugger with the php, I can single-step through the code, but the $_POST variable is empty, even if I set it to something under Run=>Parameters.

Any suggestions on how to get this to work?

thanks,

David Linker
View user's profileFind all posts by dtlinkerSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
If I start the debugger with the html page, it just runs in the browser, runs the php, but does not stop at any breakpoints I have set.

to start debugging for calc.php, you have to inform debugger that it should start. Please read FAQ on how to start debug sessions. There are many ways, btw. The simpliest is to add DBGSESSID with appropriate value into URL (or submit it as a POST variable).

Quote:
If I start the debugger with the php, I can single-step through the code, but the $_POST variable is empty, even if I set it to something under Run=>Parameters.

POST variables work with embedded IE browser only.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Resolved: Here's how I got it to work.


Joined: 09 Jul 2007
Posts: 4
Reply with quote
Even with the documentation, and advice, it took a lot of fiddling to get it to work, but here's what I had to change:

First, I changed a statement in the controlling HTML file with javascript from
theRequest.send(outtext );

to
theRequest.send('DBGSESSID=1;d%3D1&' + outtext );

Note that this is a POST, and outtext consists of a varname=values string and that theReqest is an XMLHttpRequest.

Next, with phped running, I opened the HTML file in FireFox, and pressed the button that causes the XMLHttpRequest to be executed, and it worked.

I tried with a number of other browsers, including the built-in browser, and Safari, and they did not work.
View user's profileFind all posts by dtlinkerSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
different browsers are running different objects for ajax requests. Please consult with for example XOAD or any other widely spreaded open source ajax library sources.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
How to debug server-side php that responds to XMLHttpRequest
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic