Pimcore guides & How to 1 min read
Ignoring the default Pimcore error handler in Ext JS ajax request
Find out how to ignore the default error handler that triggers in any Pimcore ajax request when the request fails with the help of our tutorial.
Do you need to make an Ajax request but don’t want to show the default Pimcore notification popup that triggers when a request fails? In that case, you would need to bypass that default Pimcore behavior somehow. There is a way to do just that, so keep reading and find out how.
Solution
If you need to refresh your memory on how to create a JS file where your logic will be and connect it to an Event Listener so it is loaded when the Pimcore starts, you can refer to one of our older guides. In the first few steps of that guide, we explained how to do precisely that.
Now that we have a place for our JS code ready, let’s overwrite that default behavior. In order to have Pimcore not show the default notification popup for failed Ajax request, it is enough to simply add a new property to your Ajax request called ignoreErrors and set it to true like in the example below:
It works like this because, in the file: vendor/pimcore/pimcore/bundles/AdminBundle/Resources/public/js/pimcore/startup.js, there is a global ajax event Ext.Ajax.on(‘requestexception’…) where this logic is defined. Inside it, you can see that the value of options[“ignoreErrors”] is checked, and only if it is true, the logic for showing the notification will trigger. By setting our ignoreErrors property to false, we simply skip everything inside.
Does it work?
To test it, you just need to trigger your Ajax request and ensure it fails. And this time, you will not see that default Pimcore notification.
Do you have more questions, or have issues while implementing this? Reach out to us; we’ll be glad to help!
Related
Pimcore guides & How to Pimcore Studio Setup Guide: Backend & Infrastructure for Developers
Step-by-step overview of Pimcore Studio backend setup, including required services, DDEV configuration, bundle installation, indexing, and production considerations. 34 min read
Pimcore guides & How to Customizing Pimcore Classification Store: Removing Grid View Duplicates and Simplifying DataHub Imports
Shared Classification Store attributes can clutter Pimcore grid views and make DataHub imports harder to maintain. This article shows how a custom implementation creates one logical attribute view… 10 min read
Pimcore guides & How to Using named API routes in separated Vue CLI generated Applications
Discover how to use named, and exposed routes via Symfony FOSJsRoutingBundle in separated Vue CLI generated Applications. 2 min read
