From fdea1970d05636847f5eace9225836b5389362e2 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 25 Jan 2011 16:13:31 +0100 Subject: [PATCH] Simplify AJAX redirect --- adminer/include/design.inc.php | 3 --- adminer/include/functions.inc.php | 4 ++-- adminer/static/functions.js | 7 +++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/adminer/include/design.inc.php b/adminer/include/design.inc.php index 903c12fb..f22dade9 100644 --- a/adminer/include/design.inc.php +++ b/adminer/include/design.inc.php @@ -14,9 +14,6 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { $title_page = $title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name(); if (is_ajax()) { header("X-AJAX-Title: " . rawurlencode($title_page)); - if ($_GET["ajax"]) { - header("X-AJAX-Redirect: " . remove_from_uri("ajax")); - } } else { $protocol = ($HTTPS ? "https" : "http"); ?> diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 3e2b8277..edb426ec 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -371,7 +371,7 @@ function auth_url($driver, $server, $username) { * @return bool */ function is_ajax() { - return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest" || $_GET["ajax"]); + return ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"); } /** Send Location header and exit @@ -388,7 +388,7 @@ function redirect($location, $message = null) { if ($location == "") { $location = "."; } - header("Location: $location" . (is_ajax() ? (strpos($location, "?") !== false ? "&" : "?") . "ajax=1" : "")); + header((is_ajax() ? "X-AJAX-Redirect" : "Location") . ": $location"); exit; } } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index d766628b..8905713d 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -194,8 +194,11 @@ function ajax(url, callback, data) { xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4) { var redirect = xmlhttp.getResponseHeader('X-AJAX-Redirect'); - if (redirect && history.replaceState) { - history.replaceState(null, '', redirect); + if (redirect) { + if (history.replaceState) { + history.replaceState(null, '', redirect); + } + return ajaxSend(redirect); } var title = xmlhttp.getResponseHeader('X-AJAX-Title'); if (title) {