mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-30 14:09:58 +08:00
show error msg when response is not valid JSON
This commit is contained in:
parent
80dca173a7
commit
e5fd39e13c
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: prpr
|
* @Author: prpr
|
||||||
* @Date: 2016-01-21 13:55:44
|
* @Date: 2016-01-21 13:55:44
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: printempw
|
||||||
* @Last Modified time: 2016-02-05 21:11:56
|
* @Last Modified time: 2016-03-13 16:00:20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -20,12 +20,13 @@ var login = function() {
|
|||||||
showMsg('alert-info', '登录中。。');
|
showMsg('alert-info', '登录中。。');
|
||||||
},
|
},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
|
console.log(json);
|
||||||
if (json.errno == 0) {
|
if (json.errno == 0) {
|
||||||
docCookies.setItem('uname', uname, null, '/');
|
docCookies.setItem('uname', uname, null, '/');
|
||||||
docCookies.setItem('token', json.token, null, '/');
|
docCookies.setItem('token', json.token, null, '/');
|
||||||
if ($('#keep').prop('checked')) {
|
if ($('#keep').prop('checked')) {
|
||||||
docCookies.setItem('uname', uname, 604800, '/');
|
docCookies.setItem('uname', uname, 604800, '/');
|
||||||
// 设置长效 token (7天)
|
// 设置长效 cookie (7天)
|
||||||
docCookies.setItem('token', json.token, 604800, '/');
|
docCookies.setItem('token', json.token, 604800, '/');
|
||||||
}
|
}
|
||||||
showAlert(json.msg);
|
showAlert(json.msg);
|
||||||
@ -34,6 +35,9 @@ var login = function() {
|
|||||||
showAlert(json.msg);
|
showAlert(json.msg);
|
||||||
showMsg('hide', '');
|
showMsg('hide', '');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(json) {
|
||||||
|
showMsg('alert-danger', '出错啦,请联系作者!<br />详细信息:'+json.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -49,7 +53,7 @@ var register = function() {
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {'uname':uname, 'passwd':passwd},
|
data: {'uname':uname, 'passwd':passwd},
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
showMsg('alert-info', 'Registering...');
|
showMsg('alert-info', '注册中...');
|
||||||
},
|
},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json.errno == 0) {
|
if (json.errno == 0) {
|
||||||
@ -65,6 +69,9 @@ var register = function() {
|
|||||||
showAlert(json.msg);
|
showAlert(json.msg);
|
||||||
showMsg('hide', "");
|
showMsg('hide', "");
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(json) {
|
||||||
|
showMsg('alert-danger', '出错啦,请联系作者!<br />详细信息:'+json.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @Author: prpr
|
* @Author: prpr
|
||||||
* @Date: 2016-01-21 13:56:40
|
* @Date: 2016-01-21 13:56:40
|
||||||
* @Last Modified by: printempw
|
* @Last Modified by: printempw
|
||||||
* @Last Modified time: 2016-03-12 21:42:31
|
* @Last Modified time: 2016-03-13 16:00:48
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -146,6 +146,9 @@ $("#upload").click(function(){
|
|||||||
if (json.cape.errno != 0) {
|
if (json.cape.errno != 0) {
|
||||||
showMsg('alert-danger', '上传披风的时候出错了:\n'+json.cape.msg);
|
showMsg('alert-danger', '上传披风的时候出错了:\n'+json.cape.msg);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(json) {
|
||||||
|
showMsg('alert-danger', '出错啦,请联系作者!<br />详细信息:'+json.responseText);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user