I use laravel 5.6 with datatables, i already enabled capture_ajax config. But ajax request is still not display


Same issue here. I have'capture_ajax' => true, but queries are not listed in the "Queries" section of Debugbar.
Debugbar: v3.1.5
Laravel v5.6.26
Same here, not seeing any queries logged for datatables ajax requests
Debugbar: v3.1.5
Laravel v5.6.27
Same issue here, I have same problem with datatable, ajax request not showing in debugbar
I think data tables does a hard exit instead of a proper response.
Same here, with an ajax request done by axios in a Vue component.
For me this happens when ajax is called on initial page load.
The reason for this is that debugbar haven't loaded yet. Probably the way to fix is to move the debugbar script to the very beginning of html head tag
On subsequent calls, queries are shown as expected.
For anyone else having this issue with DataTables, a workaround I found is to listen for the xhr.dt event and then pass the response to phpdebugbar manually.
<script>
$('body').on('xhr.dt', function (e, settings, data, xhr) {
if (typeof phpdebugbar != "undefined") {
phpdebugbar.ajaxHandler.handle(xhr);
}
});
</script>
I also had an issue with some of the response headers being blank so I just added a check for that as well:
<script>
$('body').on('xhr.dt', function (e, settings, data, xhr) {
if (typeof phpdebugbar != "undefined") {
if (xhr.getAllResponseHeaders()) {
phpdebugbar.ajaxHandler.handle(xhr);
}
}
});
</script>
Worthy of being in docs?
Thank you shawnheide for this solution. I also decided to put it in my layout blade file wrapped in a blade if so that it only even shows up in the html source when debug=true (debugbar is being used):
@if(config('app.debug'))
<script>
$('body').on('xhr.dt', function (e, settings, data, xhr) {
if (typeof phpdebugbar != "undefined") {
if (xhr.getAllResponseHeaders()) {
phpdebugbar.ajaxHandler.handle(xhr);
}
}
});
</script>
@endif
I've just experienced this same issue, a few of my ajax requests were missing & I couldn't figure out quite why. Ended up just deferring my app.js until after the debug bar.
...
</div>
<script src="{{mix('js/app.js')}}" defer></script>
</body>
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this issue is still present on the latest version of this library on supported Laravel versions, please let us know by replying to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.
Most helpful comment
For anyone else having this issue with DataTables, a workaround I found is to listen for the
xhr.dtevent and then pass the response to phpdebugbar manually.I also had an issue with some of the response headers being blank so I just added a check for that as well: