public function listen($action, $logged = 'no', $callable)
	{

		if (!is_string($action) || strlen($action) == 0)
		{
			throw new AjaxException("Invalid parameter for the action.");
		}

		// resolve callable
		if (is_callable($callable))
		{
			$this->registerWithClosure($action, $logged, $callable);
		}
		else
		{

			if (strpos($callable, '@') !== false)
			{
				$parts    = explode('@', $callable);
				$callable = $parts[0];
				$method   = $parts[1];
			}
			else
			{
				$method = 'run';// default
			}

			try
			{
				$resolvedCallback = $this->app->make($callable);
				$this->registerWithClassInstance($action, $logged, $resolvedCallback, $method);

			} catch (\Exception $e)
			{
				throw new AjaxException($e->getMessage());
			}

		}

	}
public function listen($action, $logged = 'no', $callable)
	{

		if (!is_string($action) || strlen($action) == 0)
		{
			throw new AjaxException("Invalid parameter for the action.");
		}

		// resolve callable
		if (is_callable($callable))
		{
			$this->registerWithClosure($action, $logged, $callable);
		}
		else
		{

			if (strpos($callable, '@') !== false)
			{
				$parts    = explode('@', $callable);
				$callable = $parts[0];
				$method   = $parts[1];
			}
			else
			{
				$method = 'run';// default
			}

			try
			{
				$resolvedCallback = $this->app->make($callable);
				$this->registerWithClassInstance($action, $logged, $resolvedCallback, $method);

			} catch (\Exception $e)
			{
				throw new AjaxException($e->getMessage());
			}

		}

	}
public function listen ( $ action , $ logged = 'no' , $ callable ) { if ( ! is_string ( $ action ) || strlen ( $ action ) == 0 ) { throw new AjaxException ( "Invalid parameter for the action." ) ; } // resolve callable if ( is_callable ( $ callable ) ) { $ this -> registerWithClosure ( $ action , $ logged , $ callable ) ; } else { if ( strpos ( $ callable , '@' ) !== false ) { $ parts = explode ( '@' , $ callable ) ; $ callable = $ parts [ 0 ] ; $ method = $ parts [ 1 ] ; } else { $ method = 'run' ; // default } try { $ resolvedCallback = $ this -> app -> make ( $ callable ) ; $ this -> registerWithClassInstance ( $ action , $ logged , $ resolvedCallback , $ method ) ; } catch ( \ Exception $ e ) { throw new AjaxException ( $ e -> getMessage ( ) ) ; } } }
Handle the Ajax response. Run the appropriate
action hooks used by WordPress in order to perform
POST ajax request securely.
Developers have the option to run ajax for the
Front-end, Back-end either users are logged in or not
or both.

@param string $action Your ajax 'action' name
@param string $logged Accepted values are 'no', 'yes', 'both'
@param callable|string $callable The function to run when ajax action is called
@throws AjaxException
Handle the Ajax response . Run the appropriate action hooks used by WordPress in order to perform POST ajax request securely . Developers have the option to run ajax for the Front - end Back - end either users are logged in or not or both .