Calling a method from controller using ajax



I’m trying to run a method from page controller using ajax. Here what I got until now:

On filter.php, I run the hooks:
add_action( 'wp_ajax_addBanco', ['App\PageProprietario', 'addBanco'] );
add_action( 'wp_ajax_nopriv_addBanco', ['App\PageProprietario', 'addBanco'] );

And on the controller, I wil stored the method:

public static function addBanco()

My question is: this is the correct way? The method must be static or could be public?


Static methods must be called differently.
Change this
add_action( 'wp_ajax_addBanco', ['App\PageProprietario', 'addBanco'] );
To this
add_action( 'wp_ajax_addBanco', ['App\PageProprietario::addBanco'] );


Thanks for the reply @codepuncher. But I believe the correct way is setting callback function outside the array. Like this:

add_action( 'wp_ajax_addBanco', 'App\PageProprietario::addBanco' );