App_Web::isAjaxOutput PHP Метод

isAjaxOutput() публичный Метод

Returns true if browser is going to EVAL output.
public isAjaxOutput ( ) : boolean
Результат boolean
    public function isAjaxOutput()
    {
        return isset($_POST['ajax_submit']) || $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
    }

Usage Example

Пример #1
0
Файл: Web.php Проект: atk4/atk4
 /**
  * Perform instant redirect to another page.
  *
  * @param string $page
  * @param array  $args
  */
 public function redirect($page = null, $args = array())
 {
     /*
      * Redirect to specified page. $args are $_GET arguments.
      * Use this function instead of issuing header("Location") stuff
      */
     $url = $this->url($page, $args);
     if ($this->app->isAjaxOutput()) {
         if ($_GET['cut_page']) {
             echo '<script>' . $this->app->js()->redirect($url) . '</script>Redirecting page...';
             exit;
         } else {
             $this->app->js()->redirect($url)->execute();
         }
     }
     header('Location: ' . $url);
     exit;
 }