mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
Enh: Javascript HumHub Client - better handle ajax redirects
This commit is contained in:
parent
c049a3d4a5
commit
ae9951e02f
@ -22,6 +22,7 @@ HumHub Change Log
|
||||
- Fix: Richtext with emoji only on post edit where ignored.
|
||||
- Fix: File StorageManager setContent method broken
|
||||
- Enh: Added FileHelper methods createLink & getContentContainer
|
||||
- Enh: Javascript HumHub Client - better handle ajax redirects
|
||||
|
||||
1.2.0-beta.1 (February 08, 2017)
|
||||
--------------------------------
|
||||
|
@ -17,8 +17,8 @@ humhub.module('client', function (module, require, $) {
|
||||
//Textstatus = "timeout", "error", "abort", "parsererror", "application"
|
||||
this.textStatus = textStatus;
|
||||
this.dataType = dataType;
|
||||
|
||||
var responseType = xhr.getResponseHeader('content-type');
|
||||
|
||||
var responseType = xhr.getResponseHeader('content-type');
|
||||
|
||||
// If we expect json and received json we merge the json result with our response object.
|
||||
if ((!dataType || dataType === 'json') && responseType && responseType.indexOf('json') > -1) {
|
||||
@ -162,6 +162,21 @@ humhub.module('client', function (module, require, $) {
|
||||
var error = function (xhr, textStatus, errorThrown) {
|
||||
var response = new Response(xhr, url, textStatus, cfg.dataType).setError(errorThrown);
|
||||
|
||||
if (response.status == 302) {
|
||||
|
||||
url = null;
|
||||
if (xhr.getResponseHeader('X-Pjax-Url')) {
|
||||
url = xhr.getResponseHeader('X-Pjax-Url');
|
||||
} else {
|
||||
url = xhr.getResponseHeader('X-Redirect');
|
||||
}
|
||||
|
||||
if (url !== null) {
|
||||
document.location = url;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorHandler && object.isFunction(errorHandler)) {
|
||||
errorHandler(response);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user