Skip to content
← All PrestaShop 9 errors

PrestaShop 9 errors

Call to undefined method ajaxDie() in PrestaShop 9

PrestaShop 9 removed ajaxDie() from controllers. Module AJAX actions that answered with it now fail, and buttons, filters or forms silently stop working.

The error
Call to undefined method MyModuleAjaxModuleFrontController::ajaxDie()
Removed in
PrestaShop 9.0
Usually found in
Module front and admin controllers

What happened

Many modules answer AJAX requests from a controller with $this->ajaxDie($json): print the response and stop. PrestaShop 9.0 removed ajaxDie() from the base Controller class. In PrestaShop 8 it was already only a wrapper that called ajaxRender() and then exit.

The error names your controller class, for example MyModuleAjaxModuleFrontController::ajaxDie() or AdminMyModuleController::ajaxDie(), because PHP reports the class the call was made on.

On the screen this rarely looks like an error. The AJAX request returns error 500 in the background, and the visitor only sees that "add to wishlist", a filter, a live search or a save button does nothing. Open the browser's developer tools, Network tab, to see the failing request.

The fix

ajaxRender() still exists in PrestaShop 9 and prints the response. It does not stop the script, so add exit yourself:

// Before
$this->ajaxDie(json_encode($result));

// After (works in 1.7, 8 and 9)
$this->ajaxRender(json_encode($result));
exit;

The hook actionAjaxDie<Controller><Method>Before still runs inside ajaxRender(), so modules that listen to it keep working.

Where else it hides

Look in every controller of the module: controllers/front/, controllers/admin/ and any class that extends a PrestaShop controller.

grep -rn "ajaxDie" modules/ override/

A module that used ajaxDie() often also has its own ajax.php file in the module folder. PrestaShop 9 blocks that file as well: see 403 Forbidden on a module's ajax.php.

Find every place like this before you upgrade

Where one removed call is, there are usually more. Our free PrestaShop 9 Readiness Check reads the code of every module, the theme and the overrides and lists each problem with its file and line. It only reads, nothing is changed.

Get the free check

Prefer not to fix it yourself? We upgrade stores to PrestaShop 9 for a fixed price. See the upgrade