code: public function run_ajax() {
  
  		$methods = [ 'add_movie_rating' ];
  
  		foreach ( $methods as $method ) {
  			add_action( 'wp_ajax_' . $method, [ $this->rating, $method ] );
  			add_action( 'wp_ajax_nopriv_' . $method, [ $this->rating, $method ] );
  		}
  	}
docs: Run ajax when change the rating.