Identifier "ajax" Is Not Defined

I am developing a new addon. I want to use ajax. When I try to use ajax in $mode in PHP I get the error below:

PHP Fatal error:  Uncaught InvalidArgumentException: Identifier "ajax" is not defined. in C:\wamp64\www\app\lib\vendor\pimple\pimple\src\Pimple\Container.php:95

How can I identify "AJAX"?

Hello

Show a part of your addon code

Best regards

Robert

If you run URL in your browser without using ajax, you will see such error.

Hi i have this error in checkout page i use addon and use version 4.10.4.sp1 . Can anyone help for this. When click "place order" button wants to goes order recieved page. But gives error. thanks for all
PHP Fatal Error
Uncaught Pimple\Exception\UnknownIdentifierException: Identifier "ajax" is not defined. in /var/www/vhosts/xxxxx.com/httpdocs/app/lib/vendor/pimple/pimple/src/Pimple/Container.php:101
Stack trace:
#0 /var/www/vhosts/xxxxx.com/httpdocs/app/addons/banks/payments/banks.php(51): Pimple\Container->offsetGet('ajax')
#1 /var/www/vhosts/xxxxx.com/httpdocs/app/functions/fn.cart.php(1549): include('/var/www/vhosts...')
#2 /var/www/vhosts/xxxxx.com/httpdocs/app/functions/fn.cart.php(9282): fn_start_payment(96, Array, Array)
#3 /var/www/vhosts/xxxxx.com/httpdocs/app/controllers/frontend/checkout.php(338): fn_checkout_place_order(Array, Array, Array)
#4 /var/www/vhosts/xxxxx.com/httpdocs/app/functions/fn.control.php(665): include('/var/www/vhosts...')
#5 /var/www/vhosts/xxxxx.com/httpdocs/app/functions/fn.control.php(423): fn_run_controller('/var/www/vhosts...', 'checkout', 'place_order', '', '')
#6 /var/www/vhosts/xxxxx.com/httpdocs/index.php(25): fn_dispatch()
#7 {main}
Error at
app/lib/vendor/pimple/pimple/src/Pimple/Container.php, line: 101
And banks.php in it
47 exit;
48 }else{
49
50 $redirect = fn_url("payment_notification.response?payment=banks&order_id={$order_info['order_id']}", AREA);
51 Tygh::$app['ajax']->assign('force_redirection', $redirect);
52 exit;

It is better to contact developers of the Banks addon with this issue.

As alternative try to replace

Tygh::$app['ajax']->assign('force_redirection', $redirect);

with

if (defined('AJAX_REQUEST')) {
    Tygh::$app['ajax']->assign('force_redirection', $redirect);
} else {
     fn_redirect($redirect);
}

Hi ecom thanks for all it works well

You are welcome!