You are here

function js_drupal_goto_alter in JS Callback Handler 7.2

Implements hook_drupal_goto_alter().

File

./js.module, line 316
JavaScript callback handler module.

Code

function js_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  global $_js;
  if ($_js && in_array($http_response_code, array(
    301,
    302,
    303,
    307,
  ))) {
    module_load_include('inc', 'js', 'includes/json');
    $json = js_http_response($http_response_code);

    // Enforce an absolute URL so the request handler can determine if it
    // should handle a redirect internally or just redirect the browser page.
    $options['absolute'] = TRUE;
    $json['response']['url'] = url($path, $options);
    if (!empty($options['force'])) {
      $json['response']['force'] = TRUE;
    }
    js_deliver_json($json);
  }
}