stef
stef

Reputation: 470

Symfony2, jQuery Ajax request, web debug toolbar, 500 Internal Server Error

I am developing an application with Symfony2 platform that, at one moment, makes a simple AJAX request on document ready.

jQuery.ajax({
    url: 'test.php',
    type: 'POST',
    data: {
        'test': 'test'
    },
    success: function( response ){
        jQuery( 'div#container' ).html( response );
    }
});

The problem is that on app_dev.php, where the debug toolbar is loaded, an 500 error is throwed. More precisely, the AJAX response from the 'test.php' file is received and loaded in the div container, but then, when it tries to load the toolbar, I receive an alert message:

"An error occured while loading the web debug toolbar (500: Internal Server Error). Do you want to open the profiler?"

If I open profiler, I don't see anything wrong.

If I open the xhr request for the toolbar, a FastCGI 500 error is displayed:

Module FastCgiModule

Notification ExecuteRequestHandler

Handler PHP54_via_FastCGI

Error Code 0x000000ff

If I don't try to make the AJAX request, the toolbar is loaded with no problem.

If I make the request by hand (event on a button) after the toolbar is loaded, again, no problem. If I make the request by hand (event on a button) before the toolbar is loaded the error is throwed.

Notes:

  1. This error occur only on the local machine (with ISS 7.5, PHP 5.4.14). On the production server (IIS server 8.0, same and PHP) the AJAX request is made, and the toolbar is loaded with no problems. I have replaced the php.ini on the local machine with the php.ini from the production server - same problem.

  2. Initialy AJAX request was loading the result of a simple bundle controller method, but then I have tried with a simple PHP file 'test.php', same problem.

  3. I have tried with post and get methods to make the request.

Does anyone have any ideea what goes wrong?

This is not a serious problem since I have multiple options the develop this app, but is bugging me, and I already lost a enough time with this.

PS: if it make any difference, on same machine I have developed an application - no framework - that makes, multiple simultaneos ajax requests.

Upvotes: 0

Views: 1115

Answers (1)

Paul Andrieux
Paul Andrieux

Reputation: 1847

The following will not fix your error, but provides an alternative way to possibly achieve your need. It seems you want to load asynchronously a part of your website, Symfony2 provides a solution for that: ESI render. The doc is here: http://symfony.com/doc/current/book/templating.html#asynchronous-content-with-hinclude-js

This method will create an ajax call only then your page will be rendered.

Upvotes: 1

Related Questions