Simplify AJAX redirect
This commit is contained in:
parent
4a5eb8b408
commit
fdea1970d0
|
@ -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");
|
||||
?>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue