improve reuseability of ajax error handler
This commit is contained in:
parent
c978ce5594
commit
4dcb5772a6
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: printempw
|
||||
* @Date: 2016-07-22 14:02:44
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-07-23 15:17:22
|
||||
* @Last Modified time: 2016-07-23 15:22:01
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -32,9 +32,7 @@ $('#color-submit').click(function() {
|
|||
else
|
||||
toastr.warning(json.msg);
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -69,9 +67,7 @@ function changeUserEmail(uid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -93,9 +89,7 @@ function changeUserNickName(uid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -115,9 +109,7 @@ function changeUserPwd(uid) {
|
|||
else
|
||||
toastr.warning(json.msg);
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -135,9 +127,7 @@ function changeUserScore(uid, score) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -159,9 +149,7 @@ function changePermission(uid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -181,9 +169,7 @@ function deleteUserAccount(uid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -207,9 +193,7 @@ $('body').on('change', '#preference', function() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -256,9 +240,7 @@ function ajaxChangeTexture(pid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -280,8 +262,6 @@ function changeOwner(pid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-17 10:54:22
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-07-21 18:02:56
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-07-23 15:26:48
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -72,7 +72,7 @@ $('#login-button').click(function() {
|
|||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText, 'Fatal Error', 'danger');
|
||||
showAjaxError(json);
|
||||
$('#login-button').html('登录').prop('disabled', '');
|
||||
}
|
||||
});
|
||||
|
|
@ -135,7 +135,7 @@ $('#register-button').click(function() {
|
|||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText, 'Fatal Error', 'danger');
|
||||
showAjaxError(json);
|
||||
$('#register-button').html('注册').prop('disabled', '');
|
||||
}
|
||||
});
|
||||
|
|
@ -178,7 +178,7 @@ $('#forgot-button').click(function() {
|
|||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText, 'Fatal Error', 'danger');
|
||||
showAjaxError(json);
|
||||
$('#forgot-button').html('发送').prop('disabled', '');
|
||||
}
|
||||
});
|
||||
|
|
@ -220,7 +220,7 @@ $('#reset-button').click(function() {
|
|||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText, 'Fatal Error', 'danger');
|
||||
showAjaxError(json);
|
||||
$('#reset-button').html('重置').prop('disabled', '');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: prpr
|
||||
* @Date: 2016-07-19 10:46:38
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-07-23 12:10:01
|
||||
* @Last Modified time: 2016-07-23 15:23:19
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -59,9 +59,7 @@ function ajaxAddToCloset(tid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -81,9 +79,7 @@ function removeFromCloset(tid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -213,9 +209,7 @@ function changePrivacy(tid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -235,8 +229,6 @@ function deleteTexture(tid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* @Author: printempw
|
||||
* @Date: 2016-07-16 10:02:24
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-07-21 19:53:24
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-07-23 15:23:31
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -59,9 +59,7 @@ $('body').on('click', '.player', function() {
|
|||
MSP.changeCape('');
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -73,9 +71,7 @@ function getHashFromTid(tid, callback) {
|
|||
success: function(json) {
|
||||
callback(json.hash)
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -145,9 +141,7 @@ $('body').on('click', '.item', function() {
|
|||
MSP.changeSkin('../textures/' + json.hash);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -165,9 +159,7 @@ function removeFromCloset(tid) {
|
|||
else
|
||||
toastr.warning(json.msg);
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -190,9 +182,7 @@ function setAsAvatar(tid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -250,9 +240,7 @@ $('body').on('change', '#preference', function() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -274,9 +262,7 @@ function changePlayerMame(pid, current_player_name) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -295,9 +281,7 @@ function clearTexture(pid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -317,9 +301,7 @@ function deletePlayer(pid) {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -338,9 +320,7 @@ function addNewPlayer() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -369,9 +349,7 @@ function changeNickName() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -453,9 +431,7 @@ function changeEmail() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -482,9 +458,7 @@ function deleteAccount() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -528,8 +502,6 @@ function sign() {
|
|||
toastr.warning(json.msg);
|
||||
}
|
||||
},
|
||||
error: function(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
error: showAjaxError
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ function showMsg(msg, type) {
|
|||
$("[id=msg]").removeClass().addClass("alert").addClass('alert-'+type).html(msg);
|
||||
}
|
||||
|
||||
function showAjaxError(json) {
|
||||
showModal(json.responseText.replace(/\n/g, '<br />'), 'Fatal Error(请联系作者)', 'danger');
|
||||
}
|
||||
|
||||
function isMobile() {
|
||||
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user