简体   繁体   中英

How do you disable Debug (Toolbar) for Ajax calls in Symfony2?

Does anyone know how to disable the debug toolbar for Ajax calls?

I have tried this:

$this->container->get('profiler')->disable();

but didn't work.

I have a controller that returns a string (json encoded data). And in the development environment I get

<div class="debug"></div>

at the end of string which breaks my code.

Any help is appreciated.

If you return a json string anyway just use JsonResponse in your controller.

use Symfony\Component\HttpFoundation\JsonResponse;

$response = new JsonResponse();
$response->setData(array(
    'data' => 123
));

This should do the trick.

found a leftover function from a legacy debug alternative that we have written to symfony's own debug toolbar in one of our listeners. so there was no symfony issue but a developer error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM