0

Not sure if SFDebug is any help in this situation. I am making an ajax post using jQuery. Which retrieves JSON data in my action URL and then makes a call to the Model method that executes the action. The part until my action URL, and the jQuery call to it work fine. With the data transmitted from the client to the server well received and no errors being made.

It is the part where it calls the method on the Model that is failing. My jQuery method looks like this:

$.post(url, jsonData, function(servermsg) { console.log(servermsg); }) ;

My server action is like this

public function executeMyAjaxRequest(sfWebRequest $request)
{

   if($request->isXmlHttpRequest())
   {
      // process whatever
      $servermsg =  Doctrine_Core::getTable('table')->addDataToTable($dataArray);
      return $this->renderText($servermsg);
   }

       return false;
} 

The method of concern in the Table.class.php file looks like this:

public function addDataToTable($dataArray)
{
   // process $dataArray and retrieve the necessary data   

   $data = new Data();
   $data->field = $dataArray['field'];
    .
    .
    .
   $data->save();

   return $data->id ;
}

The method fails up here in the model, when renderText in the action is returned and logged into the console, it returns the HTMl for SFDEBUG. Which indicates that it failed.

If this was not an Ajax call, I could debug it by seeing what the model method spat out, but this is a little tedious with Ajax in the mix.

Not looking for exact answers here, but more on how I can approach debugging ajax requests in a symfony environment, so if there are suggestions on how I can debug this, that would be great.

2 Answers 2

0

You must send cookie with session ide key via ajax

0

(Assuming you have XDEBUG configured on the server)

In order to trigger a debug session by an AJAX request you have to somehow make that request to send additional URL parameter XDEBUG_SESSION_START=1. For your example:

$.post(url + '?XDEBUG_SESSION_START=1', jsonData, function(servermsg) { console.log(servermsg); }) ;

You can also trigger it via cookie, but appending URL parameter usually easier.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.