From e6a08c5229a4ffad97bced37ec946d01bbfe6368 Mon Sep 17 00:00:00 2001 From: printempw Date: Sun, 23 Oct 2016 11:07:08 +0800 Subject: [PATCH] fix wrong base url when logout --- resources/assets/src/js/general.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/assets/src/js/general.js b/resources/assets/src/js/general.js index 71b7bf49..f40cd6ab 100644 --- a/resources/assets/src/js/general.js +++ b/resources/assets/src/js/general.js @@ -2,11 +2,14 @@ * @Author: printempw * @Date: 2016-09-15 10:39:41 * @Last Modified by: printempw -* @Last Modified time: 2016-09-15 10:43:32 +* @Last Modified time: 2016-10-23 11:04:11 */ 'use strict'; +// guesss base url +var base_url = (location.pathname.endsWith('user') || location.pathname.endsWith('admin')) ? "." : ".."; + function logout(with_out_confirm, callback) { if (!with_out_confirm) { swal({ @@ -21,7 +24,7 @@ function logout(with_out_confirm, callback) { type: 'success', html: json.msg }); - window.setTimeout('window.location = "../"', 1000); + window.setTimeout('window.location = "'+base_url+'/"', 1000); }); }); } else { @@ -34,7 +37,7 @@ function logout(with_out_confirm, callback) { function do_logout(callback) { $.ajax({ type: "POST", - url: "../auth/logout", + url: base_url + "/auth/logout", dataType: "json", success: function(json) { if (callback) callback(json);