NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Debug with XOAD-Libary


Joined: 19 Oct 2004
Posts: 14
Reply with quote
Hello.

I'm using the XOAD-libary (www.xoad.org) to make AJAX-calls. The problem is, I can't debug them in the PhpEd-IDE directly. Here is an examplescript:

Code:
<?php
require('xoad/xoad.php');

XOAD_Server::allowClasses('Test_Class');
if (XOAD_Server::runServer()) { exit(); }
else
{
  echo '<hml>'.XOAD_Utilities::header('xoad', false).'
    <script type="text/javascript">
      var test = '.XOAD_Client::register(new Test_Class()).';
      strResponse = test.doSomeStuff(); // make Ajax-Call
      alert(strResponse); // show the response
    </script><body></body></html>'; 
}

class Test_Class
{
  public function doSomeStuff ()
  {
    return 'the response';
  }
 
  function xoadGetMeta()
   {
      XOAD_Client::mapMethods($this, array('doSomeStuff'));
      XOAD_Client::publicMethods($this, array('doSomeStuff'));
   }
}
?>


Is assumes that "XOAD 0.6.0.0 for PHP 5 strict" (http://prdownloads.sourceforge.net/xoad/xoad-0.6.0.0-php5.zip?download) is installed in the subdir "xoad". Thats all.
If I start the debugger everything works fine. After the script has finnished, the browser makes the AJAX-call. The call reaches the IDE, the programm freezes and nothing happens. The only solution is to stopp the includet webserver. Then the folowing message appears:
Quote:
Fatal error while evaluation expression:
""

Debug session has been terminated.


If I run the script without debugging everting works. If I start the debuggin in the browser using the GET-value "DBGSESSID" it works also. The problem occurs only direct in the IDE.

Here my working enviorment:

Win XP SP2
PhpED 4.5 (Build 4513)
DBG 2.20.2
PHP 5.0.5

What can I do?

Bye
View user's profileFind all posts by m.stiffelSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
After a little investigation, I found that the problem is with synchronous call. In other words, XOAD runs request (ajax call) and is _waiting_ for the results, php script on the backend tries to run debug session, debugger tries to reach the IDE and can't do it because... it is runing XOAD which is waiting for the results...
To break this loop, you have to either use asynchronouse calls or run XOAD frontend in an external browser.
Below is code sample that shows how to make ajax call in XOAD asynchronously:

Code:
<?php
require('xoad/xoad.php');

XOAD_Server::allowClasses('Test_Class');
if (XOAD_Server::runServer()) { exit(); }
else
{
  echo '<html>'.XOAD_Utilities::header('xoad', false).'
    <script type="text/javascript">
      var test = '.XOAD_Client::register(new Test_Class()).';
      test.doSomeStuff(function(strResponse) {
           alert(strResponse); // show the response
      }); // make Ajax-Call
    </script><body></body></html>'; 
}

class Test_Class
{
  public function doSomeStuff ()
  {
    return 'the response';
  }
 
  function xoadGetMeta()
   {
      XOAD_Client::mapMethods($this, array('doSomeStuff'));
      XOAD_Client::publicMethods($this, array('doSomeStuff'));
   }
}
?>


BTW, you typed <hml> instead of <html>
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Debug with XOAD-Libary
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